File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,6 @@ const tabularOnelineClauses = expandPhrases([
4040 'CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]' ,
4141 // - update:
4242 'UPDATE [ONLY]' ,
43- 'UPDATE OF' ,
4443 'WHERE CURRENT OF' ,
4544 // - insert:
4645 'ON CONFLICT' ,
@@ -63,7 +62,7 @@ const tabularOnelineClauses = expandPhrases([
6362 'TRUNCATE [TABLE] [ONLY]' ,
6463 // other
6564 'SET SCHEMA' ,
66- 'AFTER [ INSERT] ' ,
65+ '{BEFORE | AFTER | INSTEAD OF} { INSERT | UPDATE [OF] | DELETE | TRUNCATE} ' ,
6766 'DEFERRABLE INITIALLY DEFERRED' ,
6867 // https://www.postgresql.org/docs/14/sql-commands.html
6968 'ABORT' ,
@@ -258,6 +257,7 @@ const reservedKeywordPhrases = expandPhrases([
258257 'DO {NOTHING | UPDATE}' ,
259258 'AS MATERIALIZED' ,
260259 'FOR EACH ROW' ,
260+ 'OR {INSERT | UPDATE [OF] | DELETE | TRUNCATE}' ,
261261 '{ROWS | RANGE | GROUPS} BETWEEN' ,
262262 // comparison operator
263263 'IS [NOT] DISTINCT FROM' ,
Original file line number Diff line number Diff line change @@ -273,12 +273,26 @@ describe('PostgreSqlFormatter', () => {
273273 )
274274 ) . toBe ( dedent `
275275 CREATE CONSTRAINT TRIGGER example_trigger
276- AFTER INSERT
277- OR
278- UPDATE OF column_a,
276+ AFTER INSERT OR UPDATE OF column_a,
279277 column_b ON example_table
280278 DEFERRABLE INITIALLY DEFERRED FOR EACH ROW
281279 EXECUTE PROCEDURE example_function ();
282280 ` ) ;
283281 } ) ;
282+
283+ it ( 'formats multiple CREATE TRIGGER events without treating OR as a logical operator' , ( ) => {
284+ expect (
285+ format (
286+ `create trigger Example_Trigger
287+ after insert or update or delete on Example_Table
288+ for each row
289+ execute function Example_Function ();` ,
290+ { keywordCase : 'upper' , identifierCase : 'lower' }
291+ )
292+ ) . toBe ( dedent `
293+ CREATE TRIGGER example_trigger
294+ AFTER INSERT OR UPDATE OR DELETE ON example_table FOR EACH ROW
295+ EXECUTE FUNCTION example_function ();
296+ ` ) ;
297+ } ) ;
284298} ) ;
You can’t perform that action at this time.
0 commit comments