Skip to content

Conversation

@Mehrbod2002
Copy link

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 <[email protected]>
@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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non-valid subquery generation

1 participant