Repository navigation
feat(analysis): type predicate subquery placeholders from columns - #80
Merged
omer-cengel merged 1 commit intoOct 12, 2026
Merged
Conversation
EXISTS, NOT EXISTS, [NOT] IN (SELECT ...), and comparison subqueries in a WHERE, a join ON condition, a write's WHERE, and a conflict predicate are analyzed as nested reads. Their placeholders are typed and named from columns of their own sources and of each enclosing query, so they no longer need a cast. The WHERE rules also descend into NOT, and a write's WITH clauses are in scope of its predicate subqueries.
omer-cengel
deleted the
feature/predicate-subqueries-typed-from-columns
branch
October 12, 2026 19:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Placeholders inside
EXISTS,NOT EXISTS,[NOT] IN (SELECT ...), and scalar comparison subqueries are now typed and named from columns, so membership checks and correlated filters compile without casts. A predicate subquery is analyzed as a nested read that sees its own sources first and then each enclosing query's sources, as PostgreSQL resolves correlated references.Changes
WHERErules reach them throughAND,OR,NOT, and parentheses: a read'sWHERE, a joinONcondition, anUPDATEorDELETEWHERE, anON CONFLICTtarget predicate, aDO UPDATEpredicate, and theWHEREof another analyzed nested query.NOT, soNOT (id = :id)types its placeholder.WITHclauses in scope of the predicate subqueries of itsWHEREand conflict predicates.SELECT 1, wildcards, and columns of unmapped types in a predicate subquery's select list, while still rejecting an unknown direct column there; a set operation inside a predicate subquery gets the set-operation diagnostic.NOT EXISTSfilter; update the query documentation.Scope and non-goals
= ANY (SELECT ...),IN ((SELECT ...)), a bare boolean subquery, and subqueries in a projection,GROUP BY,HAVING,ORDER BY, a written value,RETURNING, or a function argument keep their existing unanalyzed handling, where only a cast types a placeholder.:x = (SELECT ...), is not typed from it.WITHbody orFROMsubquery nested inside a predicate subquery still sees no enclosing source.