Skip to content
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
8 changes: 8 additions & 0 deletions crates/pgt_statement_splitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ mod tests {
.expect_statements(vec!["select 1 from contact", "select 1"]);
}

#[test]
fn grant() {
Tester::from("GRANT SELECT ON TABLE \"public\".\"my_table\" TO \"my_role\";")
.expect_statements(vec![
"GRANT SELECT ON TABLE \"public\".\"my_table\" TO \"my_role\";",
]);
}

#[test]
fn double_newlines() {
Tester::from("select 1 from contact\n\nselect 1\n\nselect 3").expect_statements(vec![
Expand Down
4 changes: 4 additions & 0 deletions crates/pgt_statement_splitter/src/parser/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
SyntaxKind::All,
// for UNION ... EXCEPT
SyntaxKind::Except,
// for grant
SyntaxKind::Grant,
]
.iter()
.all(|x| Some(x) != prev.as_ref())
Expand All @@ -230,6 +232,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
SyntaxKind::Also,
// for create rule
SyntaxKind::Instead,
// for grant
SyntaxKind::Grant,
]
.iter()
.all(|x| Some(x) != prev.as_ref())
Expand Down