File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
main/jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/test/select Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,9 @@ To help JSqlParsers development you are encouraged to provide
4444Also I would like to know about needed examples or documentation stuff.
4545
4646## Extensions in the latest SNAPSHOT version 0.9.8
47-
47+ * support for simple expressions within case when
48+ * rewrite of SelectBody - production, reduce of needed lookaheads results in huge parser performance improvement
49+ * please test it due to possible changes in the parse tree
4850
4951## Extensions of JSqlParser releases
5052
Original file line number Diff line number Diff line change @@ -1683,7 +1683,6 @@ Expression AndExpression() :
16831683 { result = left; }
16841684
16851685 (
1686- LOOKAHEAD(<K_AND>)
16871686 <K_AND>
16881687 (
16891688 LOOKAHEAD(Condition())
@@ -2444,12 +2443,11 @@ Expression CaseWhenExpression() #CaseWhenExpression:
24442443 <K_CASE>
24452444 (
24462445 ( clause=WhenThenSearchCondition() { whenClauses.add(clause); } )+
2447- [<K_ELSE> elseExp=SimpleExpression()]
24482446 |
24492447 (LOOKAHEAD(RegularCondition()) switchExp=RegularCondition() | switchExp=BitwiseAndOr())
24502448 ( clause=WhenThenValue() { whenClauses.add(clause); } )+
2451- [<K_ELSE> elseExp=SimpleExpression()]
24522449 )
2450+ [<K_ELSE> elseExp=SimpleExpression()]
24532451 <K_END>
24542452 {
24552453 caseExp.setSwitchExpression(switchExp);
@@ -2466,7 +2464,7 @@ WhenClause WhenThenSearchCondition():
24662464 Expression thenExp = null;
24672465}
24682466{
2469- <K_WHEN> whenExp=Expression() <K_THEN> thenExp=SimpleExpression()
2467+ <K_WHEN> (LOOKAHEAD(Expression()) whenExp=Expression() | whenExp=SimpleExpression() ) <K_THEN> thenExp=SimpleExpression()
24702468 {
24712469 whenThen.setWhenExpression(whenExp);
24722470 whenThen.setThenExpression(thenExp);
Original file line number Diff line number Diff line change @@ -1099,6 +1099,14 @@ public void testIssue371SimplifiedCase() throws JSQLParserException {
10991099 public void testIssue371SimplifiedCase2 () throws JSQLParserException {
11001100 assertSqlCanBeParsedAndDeparsed ("SELECT CASE col > 4 WHEN true THEN 1 ELSE 0 END" );
11011101 }
1102+
1103+ public void testIssue235SimplifiedCase3 () throws JSQLParserException {
1104+ assertSqlCanBeParsedAndDeparsed ("SELECT CASE WHEN (CASE WHEN (CASE WHEN (1) THEN 0 END) THEN 0 END) THEN 0 END FROM a" );
1105+ }
1106+
1107+ public void testIssue235SimplifiedCase4 () throws JSQLParserException {
1108+ assertSqlCanBeParsedAndDeparsed ("SELECT CASE WHEN (CASE WHEN (CASE WHEN (CASE WHEN (1) THEN 0 END) THEN 0 END) THEN 0 END) THEN 0 END FROM a" );
1109+ }
11021110
11031111 public void testReplaceAsFunction () throws JSQLParserException {
11041112 String statement = "SELECT REPLACE(a, 'b', c) FROM tab1" ;
You can’t perform that action at this time.
0 commit comments