Skip to content

Commit 115fcd2

Browse files
committed
fix: at time zone with column_ref in pg
1 parent b249a8c commit 115fcd2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pegjs/postgresql.pegjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3309,8 +3309,8 @@ cast_data_type
33093309
}
33103310

33113311
column_item_suffix
3312-
= 'AT' __ KW_TIME __ 'ZONE'i __ t:quoted_ident_type {
3313-
// => [{ type: 'origin'; value: string; }, quoted_ident_type]
3312+
= 'AT'i __ KW_TIME __ 'ZONE'i __ t:(quoted_ident_type / column_ref) {
3313+
// => [{ type: 'origin'; value: string; }, quoted_ident_type | column_ref]
33143314
return [
33153315
{
33163316
type: 'origin',

test/postgres.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,13 @@ describe('Postgres', () => {
16861686
`SELECT start_time::TIMESTAMP AT TIME ZONE 'UTC' AS "start_time" FROM "my_table"`
16871687
]
16881688
},
1689+
{
1690+
title: 'complex at time zone',
1691+
sql: [
1692+
'select date(cast(t.start_time at time zone loc.timezone as timestamptz)) as start_time from my_table t',
1693+
'SELECT date(CAST("t".start_time AT TIME ZONE "loc".timezone AS TIMESTAMPTZ)) AS "start_time" FROM "my_table" AS "t"',
1694+
]
1695+
},
16891696
{
16901697
title: 'create index with if not exists',
16911698
sql: [

0 commit comments

Comments
 (0)