fix: handle inline aggregates in calculation resolver

This commit is contained in:
Zach Daniel 2023-08-22 15:28:50 -04:00
parent 456588bd07
commit 83b29f7bbd
2 changed files with 4 additions and 5 deletions

View file

@ -2107,6 +2107,9 @@ defmodule Ash.Actions.Read do
|> Enum.concat([%{path: path, type: :calculation, calculation: calculation}])
end
%Ash.Query.Aggregate{} = aggregate ->
[%{path: path, type: :aggregate, aggregate: aggregate}]
other ->
cond do
Ash.Resource.Info.aggregate(query.resource, other) ->

View file

@ -98,7 +98,6 @@ defmodule Ash.Resource.Calculation.Expression do
aggs_from_this_calc =
expression
|> Ash.Filter.used_aggregates()
|> Enum.map(& &1.name)
aggs_from_calcs =
further_calculations
@ -117,15 +116,12 @@ defmodule Ash.Resource.Calculation.Expression do
}
) do
{:ok, expression} ->
expression
|> Ash.Filter.used_aggregates()
|> Enum.map(& &1.name)
Ash.Filter.used_aggregates(expression)
_ ->
[]
end
end)
|> Enum.map(& &1.name)
Enum.uniq(aggs_from_calcs ++ aggs_from_this_calc)