Skip to content

Drop manual QueryExpr to BooleanExpr conversion in using_join#748

Draft
lukaszsamson wants to merge 2 commits into
elixir-ecto:masterfrom
lukaszsamson:drop-join-on-booleanexpr-conversion
Draft

Drop manual QueryExpr to BooleanExpr conversion in using_join#748
lukaszsamson wants to merge 2 commits into
elixir-ecto:masterfrom
lukaszsamson:drop-join-on-booleanexpr-conversion

Conversation

@lukaszsamson

Copy link
Copy Markdown
Contributor

Stacked on #747 (the first commit here is that PR); only the last commit is new.

Once elixir-ecto/ecto#4765 ships, every JoinExpr.on is a real %BooleanExpr{op: :and}, so the using_join comprehensions' hand-conversion (Map.put(:__struct__, BooleanExpr) |> Map.put(:op, :and)) becomes a no-op. This drops it and tightens the comprehension matches to %BooleanExpr{}.

Blocked on the ecto release: unlike #747 (compatible both ways), this branch requires the new ecto — against released ecto 3.14 the stricter match would skip QueryExpr ons (15 test failures, verified). Merge only after #747, once the ecto change is released and the minimum ecto version here is bumped. Full suite passes (685 tests) against the ecto PR branch via ECTO_PATH.

🤖 Generated with Claude Code

lukaszsamson and others added 2 commits July 24, 2026 17:28
Ecto is changing interpolated join queries (join: x in ^query) to carry
their "on" expression as a BooleanExpr instead of a QueryExpr, since
folded wheres may hold subqueries (elixir-ecto/ecto#4765). Relax the
join.on pattern matches to the map shape so both structs are accepted.

This matters beyond the crash in join/2: the using_join comprehensions
filtered joins by on: %QueryExpr{}, so a BooleanExpr "on" would have
been silently dropped from the WHERE clause of update_all/delete_all.
Add coverage for interpolated join queries in update_all/delete_all,
which previously had none.

The relaxed patterns remain compatible with current Ecto releases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Since elixir-ecto/ecto#4765, every JoinExpr.on is a BooleanExpr with
op :and, so the using_join comprehensions no longer need to rewrite
the struct by hand before appending the join conditions to WHERE.

This requires ecto with the above change and must only ship once the
minimum ecto version is bumped accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@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! ❤️

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