Skip to content

Commit 07371d6

Browse files
author
Olivier Chédru
committed
Support ::date and ::uuid literals
1 parent bb374aa commit 07371d6

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/main/antlr4/org/dhatim/sql/lang/PSQLParser.g4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ timestamp_literal
338338

339339
date_literal
340340
: DATE date_string=Character_String_Literal
341+
| date_string=Character_String_Literal CAST_EXPRESSION DATE
341342
;
342343

343344
interval_literal
@@ -350,6 +351,7 @@ boolean_literal
350351

351352
uuid_literal
352353
: UUID uuid_string=Character_String_Literal
354+
| uuid_string=Character_String_Literal CAST_EXPRESSION UUID
353355
;
354356

355357
/*

src/test/java/org/dhatim/sql/hamcrest/QueryMatchersTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ public void testLike() {
7272
@Test
7373
public void testUUIDLiteral() {
7474
assertThat(sql("SELECT UUID 'c96ff414-8559-484c-bd43-c978130a5ee4'"), query(uuidLiteral("c96ff414-8559-484c-bd43-c978130a5ee4")));
75+
assertThat(sql("SELECT 'c96ff414-8559-484c-bd43-c978130a5ee4'::uuid"), query(uuidLiteral("c96ff414-8559-484c-bd43-c978130a5ee4")));
7576
}
7677

7778
@Test
7879
public void testDateLiteral() {
7980
assertThat(sql("SELECT DATE '2010-10-10'"), query(dateLiteral("2010-10-10")));
81+
assertThat(sql("SELECT '2010-10-10'::date"), query(dateLiteral("2010-10-10")));
8082
}
8183

8284
@Test

0 commit comments

Comments
 (0)