Skip to content

Commit dc0cdbf

Browse files
committed
fix: don't select :calculations in subquery if its been merged
1 parent 32cfc33 commit dc0cdbf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/query.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,14 @@ defmodule AshSql.Query do
521521
{String.to_existing_atom("__calculations__#{name}"), name}
522522
end)
523523

524-
new_query = %{
525-
query
526-
| select: %{select | expr: {:merge, [], [merge_base, {:%{}, [], merging}]}}
527-
}
524+
new_query =
525+
%{
526+
query
527+
| select: %{select | expr: {:merge, [], [merge_base, {:%{}, [], merging}]}}
528+
}
529+
|> Map.update!(:__ash_bindings__, fn bindings ->
530+
Map.update(bindings, :select_calculations, [], &(&1 -- [:calculations]))
531+
end)
528532

529533
{calculation_merges, aggregate_merges, new_query}
530534

0 commit comments

Comments
 (0)