Repository navigation
fix: resolve IN subquery inside EXISTS subquery - #3107
Open
abhi478jeetur-rgb wants to merge 1 commit into
Open
abhi478jeetur-rgb wants to merge 1 commit into
abhi478jeetur-rgb wants to merge 1 commit into
Conversation
Member
|
The default branch has been changed to main after we transitioned to having the source as es6 modules. Please change the target branch to |
Contributor
Author
|
Thanks for the note — I will retarget this to |
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.
An
IN (SELECT ...)nested inside anEXISTS (SELECT ...)threwTypeError: Cannot read properties of undefined (reading '0'), evenwhen nothing was correlated:
The inner
INsubquery is compiled into the statement-levelqueriesfn, but theEXISTSsubquery is compiled separately(
compileWhereExists) and never received that list, so its generatedcode failed when it evaluated
this.queriesfn[queriesidx]. This extendsthe existing
shareQueriesfnstep incompileQueries— which alreadyhands the list down to nested scalar subqueries — to the
EXISTSsubqueries as well, including
EXISTSnested inside anotherEXISTSand
EXISTSinside aUNIONbranch (which keeps its own subquerylist). No other compilation path is touched.
Fixes #3097
Tests
test/test3097.js(7 tests): the reported query,EXISTSin the select list,EXISTSinJOIN ... ON, the correlatedvariant (
WHERE z.zg = t.g), a doubly nestedINinsideEXISTS,the
UNION ALLvariant, and plainEXISTS/ plainINsanity checks.Before the fix: 1 pass / 6 fail; after: 7 pass.
sh build.sh && bun test): 2673 pass, 213 skip, 0 fail.npx prettier --checkclean on both changed files.Dialect test note
bun test/dialect/run.js(not run by the default suite) now reports 48cases newly matching SQLite across the
EXISTSpositions in thesubqueries matrix (select list,
WHERE,NOT EXISTS,HAVING,GROUP BY,JOIN ... ON, and theirUNION ALLvariants). Of the 12cases the issue mentions in
test/dialect/expected-differences, 8 nowreturn SQLite's answer. The remaining 4 use an unqualified correlation
(
WHERE wg = g/WHERE zg = g); they no longer throw, but still returnthe wrong value — the pre-existing unqualified-column correlation bug,
the same one the already-listed plain
EXISTS ... WHERE ug = gcasesshow.
expected-differencesitself is left untouched for themaintainer's own regeneration (it already had 46 stale entries on
developbefore this change).