Skip to content

Commit

Permalink
Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
manticore-projects authored Jul 13, 2021
1 parent 37dca00 commit 05157a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
| <K_THEN:"THEN">
| <K_TEMP:"TEMP">
| <K_TEMPORARY:"TEMPORARY">
| <K_TIME_KEY_EXPR : ( "CURRENT_TIMESTAMP" | "CURRENT_TIME" | "CURRENT_DATE" ) ( "()" )?>
| <K_TIME_KEY_EXPR : (
("CURRENT" ( "_" | (" ")+ ) "TIMESTAMP")
| ("CURRENT" ( "_" | (" ")+ ) "TIME")
| ("CURRENT" ( "_" | (" ")+ ) "DATE")
) ( "()" )?>
| <K_TIMEOUT:"TIMEOUT">
| <K_TO:"TO">
| <K_TOP:"TOP">
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4649,4 +4649,14 @@ public void testSelectAllOperatorIssue1140() throws JSQLParserException {
public void testSelectAllOperatorIssue1140_2() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT * FROM table t0 WHERE t0.id != all(?::uuid[])");
}

@Test
public void testDB2SpecialRegisterDateTimeIssue1249() throws JSQLParserException {
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_TIME", true);
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT TIME", true);
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_TIMESTAMP", true);
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT TIMESTAMP", true);
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT_DATE", true);
assertSqlCanBeParsedAndDeparsed("SELECT * FROM test.abc WHERE col > CURRENT DATE", true);
}
}

0 comments on commit 05157a8

Please sign in to comment.