Skip to content

Commit 911bfb0

Browse files
committed
Format TIMESTAMP WITH TIME ZONE in Trino
Fixes #936
1 parent e8d4518 commit 911bfb0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/languages/trino/trino.formatter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ const reservedKeywordPhrases = expandPhrases([
123123
'{ROWS | RANGE | GROUPS} BETWEEN',
124124
// comparison operator
125125
'IS [NOT] DISTINCT FROM',
126+
// https://trino.io/docs/current/language/types.html#timestamp-p-with-time-zone
127+
'[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE',
126128
]);
127129

128130
const reservedDataTypePhrases = expandPhrases([]);

test/trino.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,22 @@ describe('TrinoFormatter', () => {
123123
)
124124
`);
125125
});
126+
127+
// Regression test for issues #936
128+
it('formats TIMESTAMP WITH TIME ZONE syntax', () => {
129+
expect(
130+
format(`
131+
CREATE TABLE time_table (id INT,
132+
created_at TIMESTAMP WITH TIME ZONE,
133+
deleted_at TIME WITH TIME ZONE,
134+
modified_at TIMESTAMP(0) WITH TIME ZONE);`)
135+
).toBe(dedent`
136+
CREATE TABLE time_table (
137+
id INT,
138+
created_at TIMESTAMP WITH TIME ZONE,
139+
deleted_at TIME WITH TIME ZONE,
140+
modified_at TIMESTAMP(0) WITH TIME ZONE
141+
);
142+
`);
143+
});
126144
});

0 commit comments

Comments
 (0)