Skip to content

Commit 4077cf8

Browse files
authored
fix: binding error when loading aggregate (#196)
1 parent ee5a06a commit 4077cf8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/aggregate.ex

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,17 +2562,15 @@ defmodule AshSql.Aggregate do
25622562
)
25632563
)
25642564

2565-
bindings_without_aggregates =
2566-
query.__ash_bindings__.bindings
2567-
|> Enum.reject(fn
2568-
{_binding, %{type: :aggregate}} -> true
2569-
_ -> false
2570-
end)
2571-
|> Map.new()
2565+
root_binding = query.__ash_bindings__.root_binding
2566+
2567+
only_root_binding = %{
2568+
root_binding => query.__ash_bindings__.bindings[root_binding]
2569+
}
25722570

25732571
new_bindings =
25742572
query.__ash_bindings__
2575-
|> Map.put(:bindings, bindings_without_aggregates)
2573+
|> Map.put(:bindings, only_root_binding)
25762574
|> Map.delete(:__order__?)
25772575

25782576
Map.put(subquery_query, :__ash_bindings__, new_bindings)

0 commit comments

Comments
 (0)