Skip to content

Commit 05157a8

Browse files
Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME (#1252)
* Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME Fixes issue #1249 (Although there are more Special Registers which are not supported yet.) * Make the spaces mandatory Add 2 more tests
1 parent 37dca00 commit 05157a8

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,11 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
347347
| <K_THEN:"THEN">
348348
| <K_TEMP:"TEMP">
349349
| <K_TEMPORARY:"TEMPORARY">
350-
| <K_TIME_KEY_EXPR : ( "CURRENT_TIMESTAMP" | "CURRENT_TIME" | "CURRENT_DATE" ) ( "()" )?>
350+
| <K_TIME_KEY_EXPR : (
351+
("CURRENT" ( "_" | (" ")+ ) "TIMESTAMP")
352+
| ("CURRENT" ( "_" | (" ")+ ) "TIME")
353+
| ("CURRENT" ( "_" | (" ")+ ) "DATE")
354+
) ( "()" )?>
351355
| <K_TIMEOUT:"TIMEOUT">
352356
| <K_TO:"TO">
353357
| <K_TOP:"TOP">

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,4 +4649,14 @@ public void testSelectAllOperatorIssue1140() throws JSQLParserException {
46494649
public void testSelectAllOperatorIssue1140_2() throws JSQLParserException {
46504650
assertSqlCanBeParsedAndDeparsed("SELECT * FROM table t0 WHERE t0.id != all(?::uuid[])");
46514651
}
4652+
4653+
@Test
4654+
public void testDB2SpecialRegisterDateTimeIssue1249() throws JSQLParserException {
4655+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_TIME", true);
4656+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT TIME", true);
4657+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_TIMESTAMP", true);
4658+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT TIMESTAMP", true);
4659+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_DATE", true);
4660+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT DATE", true);
4661+
}
46524662
}

0 commit comments

Comments
 (0)