Skip to content

Commit 3602c5f

Browse files
committed
allowed Jdbc named parameters within interval expressions
1 parent 8bcf2dc commit 3602c5f

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

nb-configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
That way multiple projects can share the same settings (useful for formatting rules for example).
1414
Any value defined here will override the pom.xml file value but is only applicable to the current project.
1515
-->
16-
<netbeans.compile.on.save>all</netbeans.compile.on.save>
16+
<netbeans.compile.on.save>none</netbeans.compile.on.save>
1717
<com-junichi11-netbeans-changelf.enable>false</com-junichi11-netbeans-changelf.enable>
1818
<com-junichi11-netbeans-changelf.use-project>true</com-junichi11-netbeans-changelf.use-project>
1919
<com-junichi11-netbeans-changelf.lf-kind>LF</com-junichi11-netbeans-changelf.lf-kind>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3359,7 +3359,7 @@ IntervalExpression IntervalExpression() : {
33593359
{
33603360

33613361
{ interval = new IntervalExpression(); }
3362-
<K_INTERVAL> ["-" {signed=true;}] (token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> | expr = Column())
3362+
<K_INTERVAL> ["-" {signed=true;}] (token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> | expr = Column() | expr = JdbcNamedParameter() )
33633363
{
33643364
if (expr != null) {
33653365
if (signed) expr = new SignedExpression('-', expr);

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4165,4 +4165,24 @@ public void testPreserveAndOperator() throws JSQLParserException {
41654165
public void testPreserveAndOperator_2() throws JSQLParserException {
41664166
assertSqlCanBeParsedAndDeparsed("SELECT * FROM mytable WHERE (field_1 && ?)");
41674167
}
4168+
4169+
@Test
4170+
public void testCheckDateFunctionIssue() throws JSQLParserException {
4171+
assertSqlCanBeParsedAndDeparsed("SELECT DATEDIFF(NOW(), MIN(s.startTime))");
4172+
}
4173+
4174+
@Test
4175+
public void testCheckDateFunctionIssue_2() throws JSQLParserException {
4176+
assertSqlCanBeParsedAndDeparsed("SELECT DATE_SUB(NOW(), INTERVAL :days DAY)");
4177+
}
4178+
4179+
@Test
4180+
public void testCheckDateFunctionIssue_3() throws JSQLParserException {
4181+
assertSqlCanBeParsedAndDeparsed("SELECT DATE_SUB(NOW(), INTERVAL 1 DAY)");
4182+
}
4183+
4184+
@Test
4185+
public void testCheckColonVariable() throws JSQLParserException {
4186+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM mytable WHERE (col1, col2) IN ((:qp0, :qp1), (:qp2, :qp3))");
4187+
}
41684188
}

0 commit comments

Comments
 (0)