File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,17 +142,33 @@ defmodule AshSql.Join do
142142
143143 # We can't reuse joins if we're adding filters/have a separate parent binding
144144 if is_nil ( join_filters ) && is_nil ( parent_query ) && binding do
145- case join_all_relationships (
145+ full_path = Enum . map ( current_path , & & 1 . name )
146+ used_aggregates = Ash.Filter . used_aggregates ( filter , full_path )
147+
148+ case AshSql.Aggregate . add_aggregates (
146149 query ,
147- filter ,
148- opts ,
149- [ { join_type , rest_rels } ] ,
150- current_path ,
151- source ,
152- sort?
150+ used_aggregates ,
151+ relationship . destination ,
152+ false ,
153+ binding ,
154+ { query . __ash_bindings__ . resource , full_path }
153155 ) do
154156 { :ok , query } ->
155- { :cont , { :ok , query } }
157+ case join_all_relationships (
158+ query ,
159+ filter ,
160+ opts ,
161+ [ { join_type , rest_rels } ] ,
162+ current_path ,
163+ source ,
164+ sort?
165+ ) do
166+ { :ok , query } ->
167+ { :cont , { :ok , query } }
168+
169+ { :error , error } ->
170+ { :halt , { :error , error } }
171+ end
156172
157173 { :error , error } ->
158174 { :halt , { :error , error } }
You can’t perform that action at this time.
0 commit comments