From c71cf6fb340fc3a580466415618453642fcad125 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Mon, 23 Dec 2024 12:09:18 +0200 Subject: [PATCH] Support OR REPLACE in CREATE FUNCTION of PostgreSQL Refs #813 --- src/languages/postgresql/postgresql.formatter.ts | 2 +- test/postgresql.test.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 (); + `); + }); });