Skip to content

fix: properly parse trigger with instead of #383

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

Merged
merged 1 commit into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/pgt_statement_splitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,22 @@ mod tests {
Tester::from("/* this is a test */\nselect 1").expect_statements(vec!["select 1"]);
}

#[test]
fn trigger_instead_of() {
Tester::from(
"CREATE OR REPLACE TRIGGER my_trigger
INSTEAD OF INSERT ON my_table
FOR EACH ROW
EXECUTE FUNCTION my_table_trigger_fn();",
)
.expect_statements(vec![
"CREATE OR REPLACE TRIGGER my_trigger
INSTEAD OF INSERT ON my_table
FOR EACH ROW
EXECUTE FUNCTION my_table_trigger_fn();",
]);
}

#[test]
fn with_check() {
Tester::from("create policy employee_insert on journey_execution for insert to authenticated with check ((select private.organisation_id()) = organisation_id);")
Expand Down
2 changes: 2 additions & 0 deletions crates/pgt_statement_splitter/src/parser/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
SyntaxKind::For,
// e.g. on insert or delete
SyntaxKind::Or,
// e.g. INSTEAD OF INSERT
SyntaxKind::Of,
// for create rule
SyntaxKind::On,
// for create rule
Expand Down