fix(parser): parse Oracle outer join operator (+) on BETWEEN operands (#672) - #2564
Open
fudianchn wants to merge 1 commit into
Open
fix(parser): parse Oracle outer join operator (+) on BETWEEN operands (#672)#2564fudianchn wants to merge 1 commit into
fudianchn wants to merge 1 commit into
Conversation
fudianchn
marked this pull request as draft
September 8, 2026 06:58
fudianchn
force-pushed
the
fix/oracle-join-between-672
branch
from
September 8, 2026 07:09
2b729bb to
489346e
Compare
fudianchn
marked this pull request as ready for review
September 8, 2026 07:21
…JSQLParser#672) Signed-off-by: 付典 <fudianchn@gmail.com>
fudianchn
force-pushed
the
fix/oracle-join-between-672
branch
from
September 8, 2026 07:59
489346e to
b9d4405
Compare
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.
AI disclosure: this change was prepared with AI coding agents, reviewed and revised line by line by me.
What
JSqlParserCC.jjt: accept the Oracle outer join operator(+)after theBETWEENstart and end operands, mirroring the existing consumption point inCondition(). 6 new cases inBetweenTest.Why
WHERE t1.col1 BETWEEN t2.col2(+) AND t2.col3(+)fails to parse, although(+)already works on comparison operands (t1.c = t2.c(+),t1.c(+) = t2.c) and even on the left operand ofBETWEENitself (t2.col2(+) BETWEEN t1.a AND t1.b). Fixes #672.How
Today the grammar consumes
(+)at three sites: after the condition's left operand inCondition(), after the comparison right-hand side inRegularConditionRHS(), and inPrimaryExpression()only when followed by,or)(IN lists). TheBETWEENstart and end operands reach none of them. The fix adds the same[ LOOKAHEAD("(" "+" ")") "(" "+" ")" ]block after both operands inBetween(), placed after the optional comparison-suffix block so inputs likeBETWEEN t2.c(+) = 5 AND 1keep their pre-existing route, settingORACLE_JOIN_RIGHTon the operandColumnthrough the existingSupportsOldOracleJoinSyntaxinterface, so there is no AST change and deparsing comes fromColumndirectly.Root cause
Between()parses its operands viaSimpleExpression()and only continues intoRegularConditionRHS()when a comparison operator follows; no site consumes the(+)postfix on this path, soBETWEEN t2.col2(+)fails on the(token.Testing
net.sf.jsqlparser.expression.operators.relational.BetweenTest(issue form, start-only and end-only forms,NOT BETWEEN,SYMMETRICcombination, joinONclause, left-operand guard, comparison-suffix guard): 6 of 8 new cases fail on master6c726d8, all 11 pass with this change (./gradlew test --tests "...BetweenTest").ORACLE_JOIN_RIGHT.Condition()left-operand block turns only the left-operand guard red; reverting the block order (consuming(+)before the comparison suffix) turns only the comparison-suffix guard red, which asserts the marker stays on the comparison exactly as on master.(+)is directly followed by a comparison operator, the pre-existingRegularConditionRHSroute applies (marker on the comparison itself, viaisComparisonOperatorAhead), the new block only consumes(+)when that route does not apply; for a non-Columnoperand followed by(+)the token is consumed and not recorded, matching the existingCondition()left-operand semantics.JSQLParserBenchmark.parseSQLStatementsonperformance.sql,version=latest, 10 forks x 10 iterations (100 samples) per run, interleaved master -> branch -> master -> branch on a 32-core host (JDK 17):6c726d8All four runs are clean windows, the mean delta of 0.6% is within the confidence interval overlap, no regression. The new lookahead only executes inside the
BETWEENproduction.Verification of the original issue
SELECT * FROM table1 t1, table2 t2 WHERE t1.col1 BETWEEN t2.col2(+) AND t2.col3(+)6c726d8:ParseException: Encountered: <OPENING_BRACKET> / "(", at line 1, column 65ORACLE_JOIN_RIGHT, deparse is identical to the input.Fixes #672