Skip to content

Commit 81a648e

Browse files
authored
Support timestamptz dateliteral (#1621)
* support timestamptz as datetime literal * rename test
1 parent b0aae37 commit 81a648e

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/main/java/net/sf/jsqlparser/expression/DateTimeLiteralExpression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public DateTimeLiteralExpression withType(DateTime type) {
5353
}
5454

5555
public enum DateTime {
56-
DATE, TIME, TIMESTAMP;
56+
DATE, TIME, TIMESTAMP, TIMESTAMPTZ;
5757
}
5858
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
182182
| <K_CYCLE:"CYCLE">
183183
| <K_DATABASE:"DATABASE">
184184
| <K_DECLARE: "DECLARE">
185-
| <K_DATETIMELITERAL : ("DATE" | "TIME" | "TIMESTAMP") >
185+
| <K_DATETIMELITERAL : ("DATE" | "TIME" | "TIMESTAMP" | "TIMESTAMPTZ") >
186186
| <K_DATE_LITERAL : ( "YEAR" | "MONTH" | "DAY" | "HOUR" | "MINUTE" | "SECOND" ) >
187187
| <K_DBA_RECYCLEBIN: "DBA_RECYCLEBIN">
188188
| <K_DEFAULT : "DEFAULT">

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5238,4 +5238,9 @@ public void testNamedWindowDefinitionIssue1581() throws JSQLParserException {
52385238
public void testNamedWindowDefinitionIssue1581_2() throws JSQLParserException {
52395239
assertSqlCanBeParsedAndDeparsed("SELECT sum(salary) OVER w1, avg(salary) OVER w2 FROM empsalary WINDOW w1 AS (PARTITION BY depname ORDER BY salary DESC), w2 AS (PARTITION BY depname2 ORDER BY salary2)");
52405240
}
5241+
5242+
@Test
5243+
public void testTimestamptzDateTimeLiteral() throws JSQLParserException {
5244+
assertSqlCanBeParsedAndDeparsed("SELECT * FROM table WHERE x >= TIMESTAMPTZ '2021-07-05 00:00:00+00'");
5245+
}
52415246
}

0 commit comments

Comments
 (0)