From 696de7f1bf73482505cea94d7d82e96f237346a9 Mon Sep 17 00:00:00 2001 From: Alan Heywood Date: Tue, 2 Dec 2025 16:03:50 +1000 Subject: [PATCH] fix: binding error when loading aggregate --- lib/aggregate.ex | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/aggregate.ex b/lib/aggregate.ex index 47b1085..f213e4f 100644 --- a/lib/aggregate.ex +++ b/lib/aggregate.ex @@ -2562,17 +2562,15 @@ defmodule AshSql.Aggregate do ) ) - bindings_without_aggregates = - query.__ash_bindings__.bindings - |> Enum.reject(fn - {_binding, %{type: :aggregate}} -> true - _ -> false - end) - |> Map.new() + root_binding = query.__ash_bindings__.root_binding + + only_root_binding = %{ + root_binding => query.__ash_bindings__.bindings[root_binding] + } new_bindings = query.__ash_bindings__ - |> Map.put(:bindings, bindings_without_aggregates) + |> Map.put(:bindings, only_root_binding) |> Map.delete(:__order__?) Map.put(subquery_query, :__ash_bindings__, new_bindings)