Skip to content

Commit 9cd19b0

Browse files
authored
fix: properly parse trigger with instead of (#383)
1 parent 51c301a commit 9cd19b0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

crates/pgt_statement_splitter/src/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,22 @@ mod tests {
180180
Tester::from("/* this is a test */\nselect 1").expect_statements(vec!["select 1"]);
181181
}
182182

183+
#[test]
184+
fn trigger_instead_of() {
185+
Tester::from(
186+
"CREATE OR REPLACE TRIGGER my_trigger
187+
INSTEAD OF INSERT ON my_table
188+
FOR EACH ROW
189+
EXECUTE FUNCTION my_table_trigger_fn();",
190+
)
191+
.expect_statements(vec![
192+
"CREATE OR REPLACE TRIGGER my_trigger
193+
INSTEAD OF INSERT ON my_table
194+
FOR EACH ROW
195+
EXECUTE FUNCTION my_table_trigger_fn();",
196+
]);
197+
}
198+
183199
#[test]
184200
fn with_check() {
185201
Tester::from("create policy employee_insert on journey_execution for insert to authenticated with check ((select private.organisation_id()) = organisation_id);")

crates/pgt_statement_splitter/src/parser/common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
236236
SyntaxKind::For,
237237
// e.g. on insert or delete
238238
SyntaxKind::Or,
239+
// e.g. INSTEAD OF INSERT
240+
SyntaxKind::Of,
239241
// for create rule
240242
SyntaxKind::On,
241243
// for create rule

0 commit comments

Comments
 (0)