File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,8 +80,15 @@ defmodule AshSql.Aggregate do
8080 _ -> false
8181 end )
8282 |> Enum . reduce ( query , fn { agg_binding , % { aggregates: aggs } } , q ->
83+ q = update_in ( q . __ash_bindings__ , & Map . put_new ( & 1 , :select_aggregates , [ ] ) )
84+
8385 Enum . reduce ( aggs , q , fn agg , q ->
8486 if Enum . any? ( already_computed_aggregates , & ( & 1 . name == agg . name ) ) do
87+ q =
88+ update_in ( q . __ash_bindings__ . select_aggregates , fn select_aggs ->
89+ [ agg . name | select_aggs ]
90+ end )
91+
8592 if agg . default_value do
8693 from ( row in q ,
8794 select_merge: % {
@@ -2547,10 +2554,11 @@ defmodule AshSql.Aggregate do
25472554 select:
25482555 struct (
25492556 row ,
2550- ^ Enum . concat (
2557+ ^ Enum . concat ( [
25512558 selected_fields ,
2552- query . __ash_bindings__ [ :select_calculations ] || [ ]
2553- )
2559+ query . __ash_bindings__ [ :select_calculations ] || [ ] ,
2560+ query . __ash_bindings__ [ :select_aggregates ] || [ ]
2561+ ] )
25542562 )
25552563 )
25562564
You can’t perform that action at this time.
0 commit comments