mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: properly load aggregates required for keyset pagination
This commit is contained in:
parent
fa8f44dc42
commit
5ab0c08f0f
1 changed files with 13 additions and 3 deletions
|
@ -2142,17 +2142,27 @@ defmodule Ash.Actions.Read do
|
||||||
query.sort
|
query.sort
|
||||||
|> Enum.flat_map(fn
|
|> Enum.flat_map(fn
|
||||||
{%Ash.Query.Calculation{} = calc, _} ->
|
{%Ash.Query.Calculation{} = calc, _} ->
|
||||||
[calc]
|
[{:calc, calc}]
|
||||||
|
|
||||||
|
{field, _} ->
|
||||||
|
if Ash.Resource.Info.aggregate(query.resource, field) do
|
||||||
|
[{:agg, field}]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
end)
|
end)
|
||||||
|> Enum.reduce(query, fn
|
|> Enum.reduce(query, fn
|
||||||
%{load: nil} = calc, query ->
|
{:calc, %{load: nil} = calc}, query ->
|
||||||
Ash.Query.calculate(query, calc.name, {calc.module, calc.opts}, calc.type, calc.context)
|
Ash.Query.calculate(query, calc.name, {calc.module, calc.opts}, calc.type, calc.context)
|
||||||
|
|
||||||
%{load: load, context: context}, query ->
|
{:calc, %{load: load, context: context}}, query ->
|
||||||
Ash.Query.load(query, [{load, context}])
|
Ash.Query.load(query, [{load, context}])
|
||||||
|
|
||||||
|
{:agg, field}, query ->
|
||||||
|
Ash.Query.load(query, field)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
limited =
|
limited =
|
||||||
|
|
Loading…
Reference in a new issue