diff --git a/src/languages/postgresql/postgresql.formatter.ts b/src/languages/postgresql/postgresql.formatter.ts index e4213a6a64..695f11a3d2 100644 --- a/src/languages/postgresql/postgresql.formatter.ts +++ b/src/languages/postgresql/postgresql.formatter.ts @@ -27,7 +27,7 @@ const reservedClauses = expandPhrases([ 'SET', // Data definition 'CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW', - 'CREATE MATERIALIZED VIEW [IF NOT EXISTS]', + 'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]', // other 'RETURNING', ]); diff --git a/test/features/createView.ts b/test/features/createView.ts index 3d13ae80ba..fcff8800af 100644 --- a/test/features/createView.ts +++ b/test/features/createView.ts @@ -59,9 +59,12 @@ export default function supportsCreateView( } if (ifNotExists) { - it('formats short CREATE TABLE IF NOT EXISTS', () => { - expect(format('CREATE TABLE IF NOT EXISTS tbl (a INT PRIMARY KEY, b TEXT);')).toBe(dedent` - CREATE TABLE IF NOT EXISTS tbl (a INT PRIMARY KEY, b TEXT); + it('formats short CREATE VIEW IF NOT EXISTS', () => { + expect(format('CREATE VIEW IF NOT EXISTS my_view AS SELECT 42;')).toBe(dedent` + CREATE VIEW IF NOT EXISTS + my_view AS + SELECT + 42; `); }); }