Skip to content

Commit 8de0fd9

Browse files
committed
fixes #917
1 parent 9ca4f3e commit 8de0fd9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,7 @@ WhenClause WhenThenSearchCondition():
33083308
}
33093309
{
33103310
<K_WHEN> (LOOKAHEAD(Expression()) whenExp=Expression() | whenExp=SimpleExpression())
3311-
<K_THEN> thenExp=Condition()
3311+
<K_THEN> thenExp=Expression()
33123312
{
33133313
whenThen.setWhenExpression(whenExp);
33143314
whenThen.setThenExpression(thenExp);

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3982,4 +3982,18 @@ public void testWrongParseTreeIssue89() throws JSQLParserException {
39823982
.extracting(item -> item.toString())
39833983
.contains("col");
39843984
}
3985+
3986+
@Test
3987+
public void testCaseWithComplexWhenExpression() throws JSQLParserException {
3988+
assertSqlCanBeParsedAndDeparsed("SELECT av.app_id, MAX(av.version_no) AS version_no\n"
3989+
+ "FROM app_version av\n"
3990+
+ "JOIN app_version_policy avp ON av.id = avp.app_version_id\n"
3991+
+ "WHERE av.`status` = 1\n"
3992+
+ "AND CASE \n"
3993+
+ "WHEN avp.area IS NOT NULL\n"
3994+
+ "AND length(avp.area) > 0 THEN avp.area LIKE CONCAT('%,', '12', ',%')\n"
3995+
+ "OR avp.area LIKE CONCAT('%,', '13', ',%')\n"
3996+
+ "ELSE 1 = 1\n"
3997+
+ "END\n", true);
3998+
}
39853999
}

0 commit comments

Comments
 (0)