-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hi, I found an issue with pgschema dump.
It misses CREATE TRIGGER for INSTEAD OF triggers on views.
Reproduction
Schema example to reproduce the issue:
CREATE SCHEMA test;
CREATE TABLE test.users (
id serial PRIMARY KEY,
email text NOT NULL
);
CREATE VIEW test.user_emails AS
SELECT id, email
FROM test.users;
CREATE OR REPLACE FUNCTION test.insert_user_emails()
RETURNS trigger AS $$
BEGIN
INSERT INTO test.users (email)
VALUES (NEW.email)
RETURNING id, email INTO NEW.id, NEW.email;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trg_user_emails_insert
INSTEAD OF INSERT ON test.user_emails
FOR EACH ROW
EXECUTE FUNCTION test.insert_user_emails();Use pgschema dump --schema test to dump the schema after that.
Expected result
Dump includes CREATE TRIGGER trg_user_emails_insert ...
Actual result
Dump includes the view and function, but the CREATE TRIGGER statement is missing.
Possible fix
I made a local fix using AI but I understand almost nothing about the project's code. So here's the patch
pgschema-instead-of-view-trigger.patch
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels