Skip to content

Support BooleanExpr join ons - #748

Merged
josevalim merged 1 commit into
elixir-ecto:masterfrom
lukaszsamson:drop-join-on-booleanexpr-conversion
Jul 27, 2026
Merged

Support BooleanExpr join ons#748
josevalim merged 1 commit into
elixir-ecto:masterfrom
lukaszsamson:drop-join-on-booleanexpr-conversion

Conversation

@lukaszsamson

@lukaszsamson lukaszsamson commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Adapter side of elixir-ecto/ecto#4765 (fix for elixir-ecto/ecto#4763), which is now merged. Supersedes #747, whose changes are folded into this PR.

Ecto's join builder now emits every JoinExpr.on as a %BooleanExpr{op: :and} instead of a QueryExpr, so that wheres folded into the on of an interpolated join query (join: x in ^query) can carry subqueries. This matches on BooleanExpr when rendering joins, and drops the manual struct rewrite in the using_join comprehensions (Map.put(:__struct__, BooleanExpr) |> Map.put(:op, :and)), which now receive a real BooleanExpr.

Two failure modes without this change:

  • join/2 raises FunctionClauseError for any interpolated join query — loud.
  • the using_join comprehensions filtered joins by on: %QueryExpr{}, so they would silently drop the join conditions from the WHERE clause of update_all/delete_all — wrong SQL, no error. There was no coverage for interpolated join queries in update_all/delete_all, so this adds it for all three adapters.

mix deps.update ecto bumps the ecto git dep to 8959c439, which includes the change. Full suite passes (692 tests), along with mix format --check-formatted and mix deps.unlock --check-unused.

🤖 Generated with Claude Code

@josevalim

Copy link
Copy Markdown
Member

Can you merge the old PR into this one and do a mix deps.update ecto so CI passes? Thank you! ❤️

Since elixir-ecto/ecto#4765, the join builder emits every JoinExpr.on
as a %BooleanExpr{op: :and} rather than a QueryExpr, so that wheres
folded into the on of an interpolated join query can carry subqueries.

Match on BooleanExpr when rendering joins, and drop the manual struct
rewrite in the using_join comprehensions, which now receive a real
BooleanExpr.

Without this, join/2 raises for interpolated join queries, and the
using_join comprehensions silently drop the join conditions from the
WHERE clause of update_all/delete_all, as they filtered joins by
on: %QueryExpr{}. Add coverage for interpolated join queries in
update_all/delete_all, which had none.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lukaszsamson
lukaszsamson force-pushed the drop-join-on-booleanexpr-conversion branch from acbdce8 to 9c6a0c4 Compare July 27, 2026 16:26
@lukaszsamson lukaszsamson changed the title Drop manual QueryExpr to BooleanExpr conversion in using_join Support BooleanExpr join ons Jul 27, 2026
@lukaszsamson
lukaszsamson marked this pull request as ready for review July 27, 2026 16:26
@lukaszsamson

Copy link
Copy Markdown
Contributor Author

Done — #747 is folded in here (closed) and mix deps.update ecto bumps the git dep to 8959c439, which has #4765. Single commit now; mix test, mix format --check-formatted and mix deps.unlock --check-unused all pass locally.

Since ecto master always emits BooleanExpr ons, I also tightened the join matches to %BooleanExpr{} rather than keeping the permissive map patterns #747 used for cross-version compatibility.

@josevalim
josevalim merged commit 8fa4390 into elixir-ecto:master Jul 27, 2026
10 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants