Skip to content

fix: translate parent_as/1 references in correlated subqueries - #136

Open
l-vincent-l wants to merge 1 commit into
ocean:mainfrom
l-vincent-l:fix-parent-as-subquery
Open

l-vincent-l wants to merge 1 commit into
ocean:mainfrom
l-vincent-l:fix-parent-as-subquery

Conversation

@l-vincent-l

Copy link
Copy Markdown

Problem

parent_as/1 field references, used to correlate a subquery to its parent query, have no expr/3 clause in Ecto.Adapters.LibSql.Connection and fall through to the catch-all, which renders them as a bare ?:

... WHERE ((ss0s0."item_id" = ? AND ss0s0."state" = ?1))

The next bound parameter then stands in for the field, silently changing the query.

Fix

Resolve parent_as(:name).field to the source of the named parent query, as ecto_sqlite3 does. The parent query was already recorded under @parent_as by subqueries and CTEs, but never read.

Tests

Added to test/in_expression_comprehensive_test.exs, reusing its test_items / archived_items tables: an IN subquery correlated to the parent query. It fails on main. mix test --exclude turso_remote: all passing. No Rust changes.

The parent_as/1 field references that correlate a subquery to its parent
query had no expr/3 clause and fell through to the catch-all, which rendered
them as a bare `?`: the next bound parameter stood in for the field,
silently changing the query.

They are now resolved to the source of the named parent query, as in
ecto_sqlite3. The parent query was already recorded under @parent_as by
subqueries and CTEs, but never read.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a6e0ccb-7868-455b-94f8-2970c9361ab9
📥 Commits

Reviewing files that changed from the base of the PR and between dd83b45 and f3b4049.

📒 Files selected for processing: 3
  • CHANGELOG.md
  • lib/ecto/adapters/libsql/connection.ex
  • test/in_expression_comprehensive_test.exs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant