Skip to content

fix: ignore IN and FROM inside CASE when detecting named-parameter st… - #2940

Open
harryfoster2006 wants to merge 1 commit into
JSQLParser:masterfrom
harryfoster2006:fix/case-in-special-string-function
Open

harryfoster2006 wants to merge 1 commit into
JSQLParser:masterfrom
harryfoster2006:fix/case-in-special-string-function

Conversation

@harryfoster2006

@harryfoster2006 harryfoster2006 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

…ring functions

isNamedExprListAhead() scans a string function's arguments (SUBSTR, POSITION and similar) to decide whether to parse them as a named-parameter list (SUBSTR(x FROM 1 FOR 2), POSITION(a IN b)). The scan looks for top-level IN and FROM keywords. It didn't know about CASE ... END, so an IN predicate inside a CASE branch was treated as the function's own IN. That sent the parser down the wrong path and the statement failed to parse:

SELECT SUBSTR(CASE WHEN x IN (1, 2) THEN 'a' END, 1, 2) FROM B

Fix

The lookahead now tracks CASE nesting with a caseDepth counter. While inside a CASE ... END, tokens are skipped, so IN and FROM there are no longer mistaken for the function's keywords. Nested CASE expressions are handled because the counter increments and decrements.

…ring functions

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant