mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: fix aggregate.uniq?
This commit is contained in:
parent
e6c51433d0
commit
732728236e
3 changed files with 14 additions and 6 deletions
|
@ -2363,7 +2363,8 @@ defmodule Ash.Filter do
|
||||||
filterable?: aggregate.filterable?,
|
filterable?: aggregate.filterable?,
|
||||||
type: aggregate.type,
|
type: aggregate.type,
|
||||||
constraints: aggregate.constraints,
|
constraints: aggregate.constraints,
|
||||||
implementation: aggregate.implementation
|
implementation: aggregate.implementation,
|
||||||
|
uniq?: aggregate.uniq?
|
||||||
) do
|
) do
|
||||||
case parse_predicates(nested_statement, query_aggregate, context) do
|
case parse_predicates(nested_statement, query_aggregate, context) do
|
||||||
{:ok, nested_statement} ->
|
{:ok, nested_statement} ->
|
||||||
|
@ -2892,7 +2893,8 @@ defmodule Ash.Filter do
|
||||||
filterable?: aggregate.filterable?,
|
filterable?: aggregate.filterable?,
|
||||||
type: aggregate.type,
|
type: aggregate.type,
|
||||||
constraints: aggregate.constraints,
|
constraints: aggregate.constraints,
|
||||||
implementation: aggregate.implementation
|
implementation: aggregate.implementation,
|
||||||
|
uniq?: aggregate.uniq?
|
||||||
) do
|
) do
|
||||||
{:ok, %{ref | attribute: query_aggregate, resource: related}}
|
{:ok, %{ref | attribute: query_aggregate, resource: related}}
|
||||||
else
|
else
|
||||||
|
|
|
@ -936,7 +936,8 @@ defmodule Ash.Query do
|
||||||
filterable?: aggregate.filterable?,
|
filterable?: aggregate.filterable?,
|
||||||
type: aggregate.type,
|
type: aggregate.type,
|
||||||
constraints: aggregate.constraints,
|
constraints: aggregate.constraints,
|
||||||
implementation: aggregate.implementation
|
implementation: aggregate.implementation,
|
||||||
|
uniq?: aggregate.uniq?
|
||||||
) do
|
) do
|
||||||
query_aggregate = %{query_aggregate | load: field}
|
query_aggregate = %{query_aggregate | load: field}
|
||||||
new_aggregates = Map.put(query.aggregates, aggregate.name, query_aggregate)
|
new_aggregates = Map.put(query.aggregates, aggregate.name, query_aggregate)
|
||||||
|
@ -1492,7 +1493,8 @@ defmodule Ash.Query do
|
||||||
Keyword.get(opts, :filterable?, true),
|
Keyword.get(opts, :filterable?, true),
|
||||||
opts[:type],
|
opts[:type],
|
||||||
Keyword.get(opts, :constraints, []),
|
Keyword.get(opts, :constraints, []),
|
||||||
opts[:implementation]
|
opts[:implementation],
|
||||||
|
opts[:uniq?]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1511,6 +1513,7 @@ defmodule Ash.Query do
|
||||||
atom | list(atom),
|
atom | list(atom),
|
||||||
Ash.Query.t() | Keyword.t() | nil
|
Ash.Query.t() | Keyword.t() | nil
|
||||||
) :: t()
|
) :: t()
|
||||||
|
@deprecated "use `aggregate/5` instead"
|
||||||
def aggregate(
|
def aggregate(
|
||||||
query,
|
query,
|
||||||
name,
|
name,
|
||||||
|
@ -1521,7 +1524,8 @@ defmodule Ash.Query do
|
||||||
filterable? \\ true,
|
filterable? \\ true,
|
||||||
type \\ nil,
|
type \\ nil,
|
||||||
constraints \\ [],
|
constraints \\ [],
|
||||||
implementation \\ nil
|
implementation \\ nil,
|
||||||
|
uniq? \\ false
|
||||||
) do
|
) do
|
||||||
{field, agg_query} =
|
{field, agg_query} =
|
||||||
case agg_query do
|
case agg_query do
|
||||||
|
@ -1568,7 +1572,8 @@ defmodule Ash.Query do
|
||||||
filterable?: filterable?,
|
filterable?: filterable?,
|
||||||
type: type,
|
type: type,
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
implementation: implementation
|
implementation: implementation,
|
||||||
|
uniq?: uniq?
|
||||||
) do
|
) do
|
||||||
{:ok, aggregate} ->
|
{:ok, aggregate} ->
|
||||||
new_aggregates = Map.put(query.aggregates, aggregate.name, aggregate)
|
new_aggregates = Map.put(query.aggregates, aggregate.name, aggregate)
|
||||||
|
|
|
@ -14,6 +14,7 @@ defmodule Ash.Resource.Aggregate do
|
||||||
:field,
|
:field,
|
||||||
:sort,
|
:sort,
|
||||||
:default,
|
:default,
|
||||||
|
:uniq?,
|
||||||
filterable?: true
|
filterable?: true
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue