Skip to content

Commit 2c69cc6

Browse files
committed
fixes #522
1 parent f64ad89 commit 2c69cc6

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
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
@@ -2687,7 +2687,7 @@ WhenClause WhenThenValue():
26872687
Expression thenExp = null;
26882688
}
26892689
{
2690-
<K_WHEN> whenExp=PrimaryExpression() <K_THEN> thenExp=SimpleExpression()
2690+
<K_WHEN> whenExp=SimpleExpression() <K_THEN> thenExp=SimpleExpression()
26912691
{
26922692
whenThen.setWhenExpression(whenExp);
26932693
whenThen.setThenExpression(thenExp);

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

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ public void testNamedParameter2() throws JSQLParserException {
20222022
assertEquals("param2", namedParameter2.getName());
20232023
assertEquals("param3", namedParameter3.getName());
20242024
}
2025-
2025+
20262026
public void testNamedParameter3() throws JSQLParserException {
20272027
assertSqlCanBeParsedAndDeparsed("SELECT * FROM t WHERE c = :from");
20282028
}
@@ -2505,7 +2505,7 @@ public void testFunctionIssue284() throws JSQLParserException {
25052505
public void testFunctionDateTimeValues() throws JSQLParserException {
25062506
assertSqlCanBeParsedAndDeparsed("SELECT * FROM tab1 WHERE a > TIMESTAMP '2004-04-30 04:05:34.56'");
25072507
}
2508-
2508+
25092509
public void testPR73() throws JSQLParserException {
25102510
assertSqlCanBeParsedAndDeparsed("SELECT date_part('day', TIMESTAMP '2001-02-16 20:38:40')");
25112511
assertSqlCanBeParsedAndDeparsed("SELECT EXTRACT(year FROM DATE '2001-02-16')");
@@ -2591,8 +2591,8 @@ public void testForUpdateWaitParseDeparse() throws JSQLParserException {
25912591
}
25922592

25932593
/**
2594-
* Validates that a SELECT with FOR UPDATE WAIT <TIMEOUT> correctly sets a {@link Wait} with the correct timeout
2595-
* value.
2594+
* Validates that a SELECT with FOR UPDATE WAIT <TIMEOUT> correctly sets a {@link Wait} with the
2595+
* correct timeout value.
25962596
*/
25972597
public void testForUpdateWaitWithTimeout() throws JSQLParserException {
25982598
String statement = "SELECT * FROM mytable FOR UPDATE WAIT 60";
@@ -2641,33 +2641,49 @@ public void testProblemIssue437Index() throws JSQLParserException {
26412641
public void testProblemIssue445() throws JSQLParserException {
26422642
assertSqlCanBeParsedAndDeparsed("SELECT E.ID_NUMBER, row_number() OVER (PARTITION BY E.ID_NUMBER ORDER BY E.DEFINED_UPDATED DESC) rn FROM T_EMPLOYMENT E");
26432643
}
2644-
2644+
26452645
public void testProblemIssue485Date() throws JSQLParserException {
26462646
assertSqlCanBeParsedAndDeparsed("SELECT * FROM tab WHERE tab.date = :date");
26472647
}
2648-
2648+
26492649
public void testGroupByProblemIssue482() throws JSQLParserException {
26502650
assertSqlCanBeParsedAndDeparsed("SELECT SUM(orderTotalValue) AS value, MONTH(invoiceDate) AS month, YEAR(invoiceDate) AS year FROM invoice.Invoices WHERE projectID = 1 GROUP BY MONTH(invoiceDate), YEAR(invoiceDate) ORDER BY YEAR(invoiceDate) DESC, MONTH(invoiceDate) DESC");
26512651
}
2652-
2652+
26532653
public void testIssue512() throws JSQLParserException {
26542654
assertSqlCanBeParsedAndDeparsed("SELECT * FROM #tab1");
26552655
assertSqlCanBeParsedAndDeparsed("SELECT * FROM tab#tab1");
26562656
}
2657-
2657+
26582658
public void testIssue512_2() throws JSQLParserException {
26592659
assertSqlCanBeParsedAndDeparsed("SELECT * FROM $tab1");
26602660
assertSqlCanBeParsedAndDeparsed("SELECT * FROM #$tab#tab1");
26612661
assertSqlCanBeParsedAndDeparsed("SELECT * FROM #$tab1#");
26622662
assertSqlCanBeParsedAndDeparsed("SELECT * FROM $#tab1#");
26632663
}
2664-
2664+
26652665
public void testIssue514() throws JSQLParserException {
26662666
assertSqlCanBeParsedAndDeparsed("SELECT listagg(c1, ';') WITHIN GROUP (PARTITION BY 1 ORDER BY 1) col FROM dual");
26672667
}
2668-
2668+
26692669
public void testIssue508LeftRightBitwiseShift() throws JSQLParserException {
26702670
assertSqlCanBeParsedAndDeparsed("SELECT 1 << 1");
26712671
assertSqlCanBeParsedAndDeparsed("SELECT 1 >> 1");
26722672
}
2673+
2674+
public void testIssue522() throws JSQLParserException {
2675+
assertSqlCanBeParsedAndDeparsed("SELECT CASE mr.required_quantity - mr.quantity_issued WHEN 0 THEN NULL ELSE CASE SIGN(mr.required_quantity) WHEN -1 * SIGN(mr.quantity_issued) THEN mr.required_quantity - mr.quantity_issued ELSE CASE SIGN(ABS(mr.required_quantity) - ABS(mr.quantity_issued)) WHEN -1 THEN NULL ELSE mr.required_quantity - mr.quantity_issued END END END quantity_open FROM mytable", true);
2676+
}
2677+
2678+
public void testIssue522_2() throws JSQLParserException {
2679+
assertSqlCanBeParsedAndDeparsed("SELECT -1 * SIGN(mr.quantity_issued) FROM mytable");
2680+
}
2681+
2682+
public void testIssue522_3() throws JSQLParserException {
2683+
assertSqlCanBeParsedAndDeparsed("SELECT CASE SIGN(mr.required_quantity) WHEN -1 * SIGN(mr.quantity_issued) THEN mr.required_quantity - mr.quantity_issued ELSE 5 END quantity_open FROM mytable", true);
2684+
}
2685+
2686+
public void testIssue522_4() throws JSQLParserException {
2687+
assertSqlCanBeParsedAndDeparsed("SELECT CASE a + b WHEN -1 * 5 THEN 1 ELSE CASE b + c WHEN -1 * 6 THEN 2 ELSE 3 END END");
2688+
}
26732689
}

0 commit comments

Comments
 (0)