Skip to content

Do not use query.oldscope as a parameter name in CASE to close #3204 - #3208

Open
arsalankhan786777 wants to merge 1 commit into
AlaSQL:mainfrom
arsalankhan786777:fix/3204-case-in-tablefn-arg
Open

arsalankhan786777 wants to merge 1 commit into
AlaSQL:mainfrom
arsalankhan786777:fix/3204-case-in-tablefn-arg

Conversation

@arsalankhan786777

Copy link
Copy Markdown
Contributor

CASE in an argument of a table function in FROM or JOIN, such as RANGE(1, CASE WHEN 1 = 1 THEN 3 ELSE 2 END), threw SyntaxError: Invalid destructuring assignment target. The argument is compiled with query.oldscope as the context, and CaseValue.toJS used that text as the name of a parameter of the function it writes. toJS now uses a plain parameter name when the context is not an identifier. The code inside still reads the same query.oldscope, so the result does not change.

Fixes #3204

Tested:

  • New test/test3204.js (4 tests: CASE WHEN, else branch, CASE expression WHEN in RANGE in FROM, and a table function in JOIN). It fails 4/4 on origin/main and passes 4/4 with the change.
  • Full bun test run of test/test[0-9]*.js and test/test-*.js after build-only: 3057 pass, 9 fail. The 9 failures are in Test 107-B (Excel files) and Test CLI (piped input); I did not run them on origin/main, so I can not say they fail there too.
  • prettier on the two changed files.

Written with Claude Code (AI); tested locally with bun test (new test file and the full test suite) on Windows.

🤖 Generated with Claude Code

…#3204

CASE in an argument of a table function in FROM or JOIN was compiled
with query.oldscope as the name of a function parameter, which is a
SyntaxError. Use a plain name when the context is not an identifier.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CASE in an argument of a table function in FROM throws a SyntaxError: RANGE(1, CASE ...)

1 participant