Repository navigation
Conversation
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.
Why
A subquery in a selector of
SEARCHthrows instead of running (#3180):The parser puts the subquery on the list of the statement, but
Search.compilenever compiled that list, so the code of the subquery foundthis.queriesfnundefined. DELETE, UPDATE and SET already compile it this way.What changes
Search.compilecompilesthis.queriesintothis.queriesfn, asDelete.compiledoes.#doSearchcalls each selector with athisthat holdsqueriesfnand theparamsof the run, and the selectors that compile an expression (EQ,LIKE,WHERE,EX,RETURN,SET,ROW) call that expression with it. The callback ofRETURNbecomes an arrow function so it keepsthis.= ANY (SELECT ...)and= ALL (SELECT ...)readthis.query.queriesfn, and fail the same way inDELETE FROM t WHERE k = ANY (SELECT ...)onmain. That is a separate gap and I left it alone.Tests
test/test3180.js, 8 cases: IN, NOT IN, scalar subquery, EXISTS (true and false), a?parameter read by the subquery, EX and RETURN, two subqueries in one SEARCH, and a SEARCH without a subquery.bun test --preload ./test/bun-setup.js ./test/test3180.js: 8 pass, 0 fail.src/stashed: 1 pass, 7 fail.bun test --dots --preload ./test/bun-setup.js ./test/test[0-9]*.js ./test/test-*.js: 3005 pass, 213 skip, 1 fail. The failure istest2149(CLI-v); I built withnode build.jsand skipped thePACKAGE_VERSIONreplacement ofyarn build-only(bun was not installed). After running that replacement,test2149passes 15/15.prettier --list-differenton the changed files: clean.Closes #3180