Skip to content

Commit

Permalink
Support ::date and ::uuid literals
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Chédru committed Jul 22, 2022
1 parent bb374aa commit 07371d6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/antlr4/org/dhatim/sql/lang/PSQLParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ timestamp_literal

date_literal
: DATE date_string=Character_String_Literal
| date_string=Character_String_Literal CAST_EXPRESSION DATE
;

interval_literal
Expand All @@ -350,6 +351,7 @@ boolean_literal

uuid_literal
: UUID uuid_string=Character_String_Literal
| uuid_string=Character_String_Literal CAST_EXPRESSION UUID
;

/*
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/dhatim/sql/hamcrest/QueryMatchersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ public void testLike() {
@Test
public void testUUIDLiteral() {
assertThat(sql("SELECT UUID 'c96ff414-8559-484c-bd43-c978130a5ee4'"), query(uuidLiteral("c96ff414-8559-484c-bd43-c978130a5ee4")));
assertThat(sql("SELECT 'c96ff414-8559-484c-bd43-c978130a5ee4'::uuid"), query(uuidLiteral("c96ff414-8559-484c-bd43-c978130a5ee4")));
}

@Test
public void testDateLiteral() {
assertThat(sql("SELECT DATE '2010-10-10'"), query(dateLiteral("2010-10-10")));
assertThat(sql("SELECT '2010-10-10'::date"), query(dateLiteral("2010-10-10")));
}

@Test
Expand Down

0 comments on commit 07371d6

Please sign in to comment.