Skip to content

Commit a1078ea

Browse files
committed
fix: add timestamptz data type in pg
1 parent ca995fc commit a1078ea

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

pegjs/postgresql.pegjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5253,7 +5253,8 @@ KW_DATE = "DATE"i !ident_start { return 'DATE'; }
52535253
KW_DATETIME = "DATETIME"i !ident_start { return 'DATETIME'; }
52545254
KW_ROWS = "ROWS"i !ident_start { return 'ROWS'; }
52555255
KW_TIME = "TIME"i !ident_start { return 'TIME'; }
5256-
KW_TIMESTAMP= "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; }
5256+
KW_TIMESTAMP = "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; }
5257+
KW_TIMESTAMPTZ = "TIMESTAMPTZ"i!ident_start { return 'TIMESTAMPTZ'; }
52575258
KW_TRUNCATE = "TRUNCATE"i !ident_start { return 'TRUNCATE'; }
52585259
KW_USER = "USER"i !ident_start { return 'USER'; }
52595260
KW_UUID = "UUID"i !ident_start { return 'UUID'; }
@@ -5673,8 +5674,9 @@ timezone
56735674
}
56745675

56755676
time_type
5676-
= t:(KW_TIME / KW_TIMESTAMP) __ LPAREN __ l:[0-9]+ __ RPAREN __ tz:timezone? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true, suffix: tz }; }
5677+
= t:(KW_TIME / KW_TIMESTAMP / KW_TIMESTAMPTZ) __ LPAREN __ l:[0-9]+ __ RPAREN __ tz:timezone? { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true, suffix: tz }; }
56775678
/ t:(KW_TIME / KW_TIMESTAMP) __ tz:timezone? { /* => data_type */ return { dataType: t, suffix: tz }; }
5679+
/ t:KW_TIMESTAMPTZ { /* => data_type */ return { dataType: t }; }
56785680

56795681
datetime_type
56805682
= t:(KW_DATE / KW_DATETIME) __ LPAREN __ l:[0-9]+ __ RPAREN { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true }; }

test/postgres.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,6 +1624,13 @@ describe('Postgres', () => {
16241624
`SELECT '{"a": {"b":{"c": "foo"}}}'::JSON #> '{a,b}', '{"a":1, "b":2}'::JSONB @> '{"b":2}'::JSONB, '{"a":1, "b":2}'::JSONB ? 'b', '{"a":1, "b":2, "c":3}'::JSONB ?| ARRAY['b','c'], '["a", "b"]'::JSONB ?& ARRAY['a','b'], '["a", "b"]'::JSONB || '["c", "d"]'::JSONB, '{"a": "b"}'::JSONB - 'a', '["a", "b"]'::JSONB - 1, '["a", {"b":1}]'::JSONB #- '{1,b}'`
16251625
]
16261626
},
1627+
{
1628+
title: 'timestamptz data type',
1629+
sql: [
1630+
'CREATE TABLE "Users" (created_at timestamptz);',
1631+
'CREATE TABLE "Users" (created_at TIMESTAMPTZ)'
1632+
]
1633+
},
16271634
]
16281635
function neatlyNestTestedSQL(sqlList){
16291636
sqlList.forEach(sqlInfo => {

0 commit comments

Comments
 (0)