Skip to content

Commit

Permalink
- allowed simple expressions in case else
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed May 15, 2012
1 parent 2129603 commit 54d2c54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,11 @@ Expression CaseWhenExpression():
<K_CASE>
(
( clause=WhenThenSearchCondition() { whenClauses.add(clause); } )+
[<K_ELSE> elseExp=PrimaryExpression()]
[<K_ELSE> elseExp=SimpleExpression()]
|
switchExp=PrimaryExpression()
( clause=WhenThenValue() { whenClauses.add(clause); } )*
[<K_ELSE> elseExp=PrimaryExpression()]
[<K_ELSE> elseExp=SimpleExpression()]
)
<K_END>
{
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/net/sf/jsqlparser/test/select/SelectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,11 @@ public void testCastInCast2() throws JSQLParserException {
String stmt = "SELECT CAST('test' + CAST(assertEqual AS numeric) AS varchar) FROM tabelle1";
assertSqlCanBeParsedAndDeparsed(stmt);
}

public void testCaseElseAddition() throws JSQLParserException {
String stmt = "SELECT CASE WHEN 1 + 3 > 20 THEN 0 ELSE 1000 + 1 END AS d FROM dual";
assertSqlCanBeParsedAndDeparsed(stmt);
}

private void assertSqlCanBeParsedAndDeparsed(String statement) throws JSQLParserException {
Statement parsed = parserManager.parse(new StringReader(statement));
Expand Down

0 comments on commit 54d2c54

Please sign in to comment.