Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSql Dialect - Support for CREATE OR REPLACE TRIGGER #4812

Open
griffio opened this issue Nov 14, 2023 · 0 comments
Open

PostgreSql Dialect - Support for CREATE OR REPLACE TRIGGER #4812

griffio opened this issue Nov 14, 2023 · 0 comments
Labels

Comments

@griffio
Copy link
Contributor

griffio commented Nov 14, 2023

SQLDelight Version

2.0.x

SQLDelight Dialect

PostgreSql

Describe the Bug

Add better support for PostgreSql triggers - include execute function/procedure

It may be only existing functions/procedures can be called as CREATE FUNCTION is not likely to be supported in SqlDelight - there is a subset for trigger functions https://www.postgresql.org/docs/current/plpgsql-trigger.html

Extracted from this request for CREATE FUNCTION #4795

https://www.postgresql.org/docs/current/sql-createtrigger.html

CREATE [ OR REPLACE ] [ CONSTRAINT ] TRIGGER name { BEFORE | AFTER | INSTEAD OF } { event [ OR ... ] }
    ON table_name
    [ FROM referenced_table_name ]
    [ NOT DEFERRABLE | [ DEFERRABLE ] [ INITIALLY IMMEDIATE | INITIALLY DEFERRED ] ]
    [ REFERENCING { { OLD | NEW } TABLE [ AS ] transition_relation_name } [ ... ] ]
    [ FOR [ EACH ] { ROW | STATEMENT } ]
    [ WHEN ( condition ) ]
    EXECUTE { FUNCTION | PROCEDURE } function_name ( arguments )

where event can be one of:

    INSERT
    UPDATE [ OF column_name [, ... ] ]
    DELETE
    TRUNCATE

The sql-psi grammar would have to be replaced in the postgresql.bnf

https://github.com/AlecKazakova/sql-psi/blob/fb53ff362381020388407bed11189b89bfe9bf1b/core/src/main/kotlin/com/alecstrong/sql/psi/core/sql.bnf#L134-L139

Stacktrace

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant