Skip to content

Commit

Permalink
Remove incorrect subquery parameter check (#4490)
Browse files Browse the repository at this point in the history
thanks very much for finding this @zachdaniel and apologies for the bug
  • Loading branch information
zachdaniel authored Aug 12, 2024
1 parent 92f07d8 commit d505995
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
6 changes: 1 addition & 5 deletions lib/ecto/query/planner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,7 @@ defmodule Ecto.Query.Planner do
{schema_or_source, expr, %{select: select} = query} =
rewrite_subquery_select_expr(query, source?)

{expr, counter} = prewalk(expr, :select, query, select, 0, adapter)

if counter != length(select.params) do
error!(query, "subqueries cannot select_merge onto an existing field that has an interpolation")
end
{expr, _} = prewalk(expr, :select, query, select, 0, adapter)

{{:map, types}, fields, _from} =
collect_fields(expr, [], :none, query, select.take, true, %{})
Expand Down
9 changes: 0 additions & 9 deletions test/ecto/query/subquery_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -563,14 +563,5 @@ defmodule Ecto.Query.SubqueryTest do

assert Macro.to_string(planned_q.from.source.query.select.expr) == "%{id: ^0, text: ^1}"
end

test "overlapping interpolations are allowed" do
msg = ~r"subqueries cannot select_merge onto an existing field that has an interpolation"

assert_raise Ecto.SubQueryError, msg, fn ->
q = from c in Comment, select: %{id: ^1}, select_merge: %{id: ^2}
from(s in subquery(q)) |> plan()
end
end
end
end

0 comments on commit d505995

Please sign in to comment.