Failing SQL Feature:
Using the PostgreSQL jsonb existence operator ? in a condition that also contains a JDBC named parameter (:name).
The ternary lookahead introduced with the ClickHouse ternary support (#2466) treats any standalone : at bracket depth 0 as the ternary else separator. A JDBC named parameter starts with exactly the same : token, so the parser commits to the ternary reading of the ? and then fails waiting for its closing :.
SQL Example:
SELECT * FROM t WHERE j ? :key
SELECT * FROM t WHERE j ? 'k' AND x = :p
Both throw a JSQLParserException on current master, although SELECT * FROM t WHERE j ? 'k' (no named parameter) and SELECT * FROM t WHERE x = :p (no ?) each parse fine. Both statements parsed fine on the commit right before #2466 (verified on 2989cb1: j ? :key parses as a JsonOperator with a named parameter operand), so this is a regression introduced by #2466.
Verified on master 7b64825.
The ternary else separator can only follow a token which can END an expression (identifier, literal, JDBC parameter, balanced closing bracket), because the then-branch must be a complete expression. A : in operand position (directly after an operator such as =, AND, or directly after the leading ?) starts a named parameter instead and must not close the then-branch.
Software Information:
- JSqlParser version: 5.4-SNAPSHOT (master 7b64825)
- Database: PostgreSQL
Failing SQL Feature:
Using the PostgreSQL jsonb existence operator
?in a condition that also contains a JDBC named parameter (:name).The ternary lookahead introduced with the ClickHouse ternary support (#2466) treats any standalone
:at bracket depth 0 as the ternary else separator. A JDBC named parameter starts with exactly the same:token, so the parser commits to the ternary reading of the?and then fails waiting for its closing:.SQL Example:
Both throw a
JSQLParserExceptionon current master, althoughSELECT * FROM t WHERE j ? 'k'(no named parameter) andSELECT * FROM t WHERE x = :p(no?) each parse fine. Both statements parsed fine on the commit right before #2466 (verified on 2989cb1:j ? :keyparses as aJsonOperatorwith a named parameter operand), so this is a regression introduced by #2466.Verified on master 7b64825.
The ternary else separator can only follow a token which can END an expression (identifier, literal, JDBC parameter, balanced closing bracket), because the then-branch must be a complete expression. A
:in operand position (directly after an operator such as=,AND, or directly after the leading?) starts a named parameter instead and must not close the then-branch.Software Information: