pgFormatter
pgFormatter copied to clipboard
Improper formatting for `TRIGGER`s when `OR REPLACE` is used
When formatting a trigger, using OR REPLACE will cause bad indentation.
Here's a fully reproducible file with the two behaviors marked with comments:
create table if not exists my_table (
id serial primary key,
updated_at timestamp not null default now()
);
create or replace function trigger_set_timestamp ()
returns trigger
language plpgsql
as $$
begin
new.updated_at := current_timestamp;
return new;
end;
$$;
-- Improper indentation with `OR REPLACE`
create or replace trigger set_timestamp before update on my_table for each row execute function trigger_set_timestamp ();
-- Proper indentation without `OR REPLACE`
create trigger set_timestamp
before update on my_table for each row
execute function trigger_set_timestamp ();