Skip to content

Commit ad78021

Browse files
committed
Fix formatting of parameterized TIMESTAMP() WITH TIME ZONE
Fixes #618
1 parent 723e9dd commit ad78021

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/languages/postgresql/postgresql.formatter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const reservedPhrases = expandPhrases([
246246
'ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]',
247247
'{ROWS | RANGE | GROUPS} BETWEEN',
248248
// https://www.postgresql.org/docs/current/datatype-datetime.html
249-
'{TIMESTAMP | TIME} {WITH | WITHOUT} TIME ZONE',
249+
'[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE',
250250
// comparison operator
251251
'IS [NOT] DISTINCT FROM',
252252
]);

test/postgresql.test.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,21 @@ describe('PostgreSqlFormatter', () => {
213213
`);
214214
});
215215

216-
// Regression test for issue #391
216+
// Regression test for issues #391 and #618
217217
it('formats TIMESTAMP WITH TIME ZONE syntax', () => {
218218
expect(
219-
format(
220-
'CREATE TABLE time_table (id INT, created_at TIMESTAMP WITH TIME ZONE, deleted_at TIME WITH TIME ZONE);'
221-
)
219+
format(`
220+
CREATE TABLE time_table (id INT,
221+
created_at TIMESTAMP WITH TIME ZONE,
222+
deleted_at TIME WITH TIME ZONE,
223+
modified_at TIMESTAMP(0) WITH TIME ZONE);`)
222224
).toBe(dedent`
223225
CREATE TABLE
224226
time_table (
225227
id INT,
226228
created_at TIMESTAMP WITH TIME ZONE,
227-
deleted_at TIME WITH TIME ZONE
229+
deleted_at TIME WITH TIME ZONE,
230+
modified_at TIMESTAMP(0) WITH TIME ZONE
228231
);
229232
`);
230233
});

0 commit comments

Comments
 (0)