fix: properly add filters for exists aggregates

closes: #173
This commit is contained in:
Zach Daniel 2023-11-17 07:46:43 -05:00
parent cef3d20eaf
commit 33bd0a7061

View file

@ -94,10 +94,17 @@ defmodule AshPostgres.Aggregate do
is_single? && Enum.at(aggregates, 0).kind == :exists ->
[aggregate] = aggregates
expr =
if is_nil(Map.get(aggregate.query, :filter)) do
true
else
Map.get(aggregate.query, :filter)
end
exists =
AshPostgres.Expr.dynamic_expr(
query,
%Ash.Query.Exists{path: aggregate.relationship_path, expr: true},
%Ash.Query.Exists{path: aggregate.relationship_path, expr: expr},
query.__ash_bindings__
)