Skip to content

Implement DB2 Special Register Date Time CURRENT DATE and CURRENT TIME #1252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -4638,4 +4638,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);
}
}