diff --git a/src/languages/postgresql/postgresql.formatter.ts b/src/languages/postgresql/postgresql.formatter.ts index 38909b835f..700d8b9791 100644 --- a/src/languages/postgresql/postgresql.formatter.ts +++ b/src/languages/postgresql/postgresql.formatter.ts @@ -246,7 +246,7 @@ const reservedPhrases = expandPhrases([ 'ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]', '{ROWS | RANGE | GROUPS} BETWEEN', // https://www.postgresql.org/docs/current/datatype-datetime.html - '{TIMESTAMP | TIME} {WITH | WITHOUT} TIME ZONE', + '[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE', // comparison operator 'IS [NOT] DISTINCT FROM', ]); diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index cce7bf8c96..607f376a97 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -213,18 +213,21 @@ describe('PostgreSqlFormatter', () => { `); }); - // Regression test for issue #391 + // Regression test for issues #391 and #618 it('formats TIMESTAMP WITH TIME ZONE syntax', () => { expect( - format( - 'CREATE TABLE time_table (id INT, created_at TIMESTAMP WITH TIME ZONE, deleted_at TIME WITH TIME ZONE);' - ) + format(` + CREATE TABLE time_table (id INT, + created_at TIMESTAMP WITH TIME ZONE, + deleted_at TIME WITH TIME ZONE, + modified_at TIMESTAMP(0) WITH TIME ZONE);`) ).toBe(dedent` CREATE TABLE time_table ( id INT, created_at TIMESTAMP WITH TIME ZONE, - deleted_at TIME WITH TIME ZONE + deleted_at TIME WITH TIME ZONE, + modified_at TIMESTAMP(0) WITH TIME ZONE ); `); });