Skip to content

Commit

Permalink
Merge pull request #2063 from taozhi8833998/fix-timestamptz-pg
Browse files Browse the repository at this point in the history
fix: add timestamptz data type in pg
  • Loading branch information
taozhi8833998 authored Aug 13, 2024
2 parents 5fe64fd + a1078ea commit 4185a54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pegjs/postgresql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -5253,7 +5253,8 @@ KW_DATE = "DATE"i !ident_start { return 'DATE'; }
KW_DATETIME = "DATETIME"i !ident_start { return 'DATETIME'; }
KW_ROWS = "ROWS"i !ident_start { return 'ROWS'; }
KW_TIME = "TIME"i !ident_start { return 'TIME'; }
KW_TIMESTAMP= "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; }
KW_TIMESTAMP = "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; }
KW_TIMESTAMPTZ = "TIMESTAMPTZ"i!ident_start { return 'TIMESTAMPTZ'; }
KW_TRUNCATE = "TRUNCATE"i !ident_start { return 'TRUNCATE'; }
KW_USER = "USER"i !ident_start { return 'USER'; }
KW_UUID = "UUID"i !ident_start { return 'UUID'; }
Expand Down Expand Up @@ -5673,8 +5674,9 @@ timezone
}

time_type
= 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 }; }
= 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 }; }
/ t:(KW_TIME / KW_TIMESTAMP) __ tz:timezone? { /* => data_type */ return { dataType: t, suffix: tz }; }
/ t:KW_TIMESTAMPTZ { /* => data_type */ return { dataType: t }; }

datetime_type
= t:(KW_DATE / KW_DATETIME) __ LPAREN __ l:[0-9]+ __ RPAREN { /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true }; }
Expand Down
7 changes: 7 additions & 0 deletions test/postgres.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,13 @@ describe('Postgres', () => {
`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}'`
]
},
{
title: 'timestamptz data type',
sql: [
'CREATE TABLE "Users" (created_at timestamptz);',
'CREATE TABLE "Users" (created_at TIMESTAMPTZ)'
]
},
]
function neatlyNestTestedSQL(sqlList){
sqlList.forEach(sqlInfo => {
Expand Down

0 comments on commit 4185a54

Please sign in to comment.