Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

sqlite: reject invalid qualified column references in correlated subqueries #4249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Mehrbod2002 wants to merge 1 commit into sqlc-dev:main
base: main
Choose a base branch
Loading
from Mehrbod2002:sqlite-invalid-correlated-ref

Conversation

@Mehrbod2002
Copy link

@Mehrbod2002 Mehrbod2002 commented Dec 30, 2025

SQLite allows some invalid correlated references to parse successfully but
fails at runtime (e.g. referencing a table alias that is not in scope).

sqlc previously accepted these queries. This PR adds a SQLite-specific
validator that walks the AST with a parent-linked scope chain and rejects
qualified column references whose table/alias is not visible.

A new end-to-end regression test reproduces the issue and verifies the fix.

Fixes: #4223

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🔧 golang labels Dec 30, 2025
- Validate qualified column references across scopes
- Reject invalid qualified refs in correlated subqueries
- Validate qualified refs in subqueries
Signed-off-by: Amirhossein Akhlaghpour <m9.akhlaghpoor@gmail.com>
@Mehrbod2002 Mehrbod2002 force-pushed the sqlite-invalid-correlated-ref branch from 1007c8e to 21c1c9a Compare December 30, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

size:L This PR changes 100-499 lines, ignoring generated files. 🔧 golang

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Non-valid subquery generation

1 participant

AltStyle によって変換されたページ (->オリジナル) /