Skip to content

Commit 5783b65

Browse files
committed
fixes #864
1 parent 8d43fac commit 5783b65

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3196,7 +3196,8 @@ AnalyticExpression AnalyticExpression(Function function) :
31963196

31973197
"("
31983198
[<K_PARTITION> <K_BY>
3199-
(LOOKAHEAD(3) expressionList=SimpleExpressionList() | "(" {partitionByBrackets = true;} expressionList=SimpleExpressionList() ")" )
3199+
(LOOKAHEAD(ComplexExpressionList()) expressionList=ComplexExpressionList()
3200+
| "(" {partitionByBrackets = true;} expressionList=ComplexExpressionList() ")" )
32003201
]
32013202
[olist=OrderByElements() ]
32023203
[windowElement = WindowElement() ]

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,16 @@ public void testAnalyticFunctionIssue670() throws JSQLParserException {
19001900
public void testAnalyticFunctionFilterIssue866() throws JSQLParserException {
19011901
assertSqlCanBeParsedAndDeparsed("SELECT COUNT(*) FILTER (WHERE name = 'Raj') OVER (PARTITION BY name ) FROM table");
19021902
}
1903+
1904+
@Test
1905+
public void testAnalyticPartitionBooleanExpressionIssue864() throws JSQLParserException {
1906+
assertSqlCanBeParsedAndDeparsed("SELECT COUNT(*) OVER (PARTITION BY (event = 'admit' OR event = 'family visit') ORDER BY day ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) family_visits FROM patients");
1907+
}
1908+
1909+
@Test
1910+
public void testAnalyticPartitionBooleanExpressionIssue864_2() throws JSQLParserException {
1911+
assertSqlCanBeParsedAndDeparsed("SELECT COUNT(*) OVER (PARTITION BY (event = 'admit' OR event = 'family visit') ) family_visits FROM patients");
1912+
}
19031913

19041914
@Test
19051915
public void testFunctionLeft() throws JSQLParserException {

0 commit comments

Comments
 (0)