fix: set proper query aggregate when fetching aggregate values

This commit is contained in:
Zach Daniel 2023-01-30 21:31:16 -05:00
parent c2dfaf75f2
commit d101c05918
2 changed files with 6 additions and 4 deletions

View file

@ -2119,7 +2119,7 @@ defmodule Ash.Filter do
if !related do
raise """
Could not determined related for `exists/2` expression.
Could not determine related resource for `exists/2` expression.
Context Resource: #{inspect(context)}
Context Relationship Path: #{inspect(context[:relationship_path])}

View file

@ -214,7 +214,6 @@ defmodule Ash.Query.Aggregate do
request =
value_request(
initial_query,
related,
relationship_path,
aggregates,
auth_request,
@ -284,7 +283,6 @@ defmodule Ash.Query.Aggregate do
defp value_request(
initial_query,
related,
relationship_path,
aggregates,
auth_request,
@ -303,7 +301,11 @@ defmodule Ash.Query.Aggregate do
Request.new(
resource: aggregate_resource,
api: initial_query.api,
query: Ash.Query.for_read(related, Ash.Resource.Info.primary_action!(related, :read).name),
query:
Ash.Query.for_read(
aggregate_resource,
Ash.Resource.Info.primary_action!(aggregate_resource, :read).name
),
path: request_path ++ [:aggregate_values, relationship_path],
action: Ash.Resource.Info.primary_action(aggregate_resource, :read),
name: "fetch aggregate: #{Enum.join(relationship_path, ".")}",