Skip to content

Commit

Permalink
Merge pull request #2235 from taozhi8833998/fix-at-time-zone-pg
Browse files Browse the repository at this point in the history
fix: at time zone with column_ref in pg
  • Loading branch information
taozhi8833998 authored Nov 27, 2024
2 parents 527ae05 + 115fcd2 commit b109b29
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pegjs/postgresql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -3309,8 +3309,8 @@ cast_data_type
}

column_item_suffix
= 'AT' __ KW_TIME __ 'ZONE'i __ t:quoted_ident_type {
// => [{ type: 'origin'; value: string; }, quoted_ident_type]
= 'AT'i __ KW_TIME __ 'ZONE'i __ t:(quoted_ident_type / column_ref) {
// => [{ type: 'origin'; value: string; }, quoted_ident_type | column_ref]
return [
{
type: 'origin',
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,13 @@ describe('Postgres', () => {
`SELECT start_time::TIMESTAMP AT TIME ZONE 'UTC' AS "start_time" FROM "my_table"`
]
},
{
title: 'complex at time zone',
sql: [
'select date(cast(t.start_time at time zone loc.timezone as timestamptz)) as start_time from my_table t',
'SELECT date(CAST("t".start_time AT TIME ZONE "loc".timezone AS TIMESTAMPTZ)) AS "start_time" FROM "my_table" AS "t"',
]
},
{
title: 'create index with if not exists',
sql: [
Expand Down

0 comments on commit b109b29

Please sign in to comment.