diff --git a/src/languages/postgresql/postgresql.formatter.ts b/src/languages/postgresql/postgresql.formatter.ts index 1f41f2c49..00eb8da9c 100644 --- a/src/languages/postgresql/postgresql.formatter.ts +++ b/src/languages/postgresql/postgresql.formatter.ts @@ -126,7 +126,7 @@ const tabularOnelineClauses = expandPhrases([ 'CREATE EXTENSION', 'CREATE FOREIGN DATA WRAPPER', 'CREATE FOREIGN TABLE', - 'CREATE FUNCTION', + 'CREATE [OR REPLACE] FUNCTION', 'CREATE GROUP', 'CREATE INDEX', 'CREATE LANGUAGE', diff --git a/test/postgresql.test.ts b/test/postgresql.test.ts index c46418a65..92967a4a4 100644 --- a/test/postgresql.test.ts +++ b/test/postgresql.test.ts @@ -383,4 +383,11 @@ describe('PostgreSqlFormatter', () => { foo operator ( !== ) bar; `); }); + + // Issue #813 + it('supports OR REPLACE in CREATE FUNCTION', () => { + expect(format(`CREATE OR REPLACE FUNCTION foo ();`)).toBe(dedent` + CREATE OR REPLACE FUNCTION foo (); + `); + }); });