Skip to content

Commit 6b3447c

Browse files
authored
fix: split grant stmt properly (#350)
1 parent 13b661e commit 6b3447c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/pgt_statement_splitter/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ mod tests {
105105
.expect_statements(vec!["select 1 from contact", "select 1"]);
106106
}
107107

108+
#[test]
109+
fn grant() {
110+
Tester::from("GRANT SELECT ON TABLE \"public\".\"my_table\" TO \"my_role\";")
111+
.expect_statements(vec![
112+
"GRANT SELECT ON TABLE \"public\".\"my_table\" TO \"my_role\";",
113+
]);
114+
}
115+
108116
#[test]
109117
fn double_newlines() {
110118
Tester::from("select 1 from contact\n\nselect 1\n\nselect 3").expect_statements(vec![

crates/pgt_statement_splitter/src/parser/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
205205
SyntaxKind::All,
206206
// for UNION ... EXCEPT
207207
SyntaxKind::Except,
208+
// for grant
209+
SyntaxKind::Grant,
208210
]
209211
.iter()
210212
.all(|x| Some(x) != prev.as_ref())
@@ -230,6 +232,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
230232
SyntaxKind::Also,
231233
// for create rule
232234
SyntaxKind::Instead,
235+
// for grant
236+
SyntaxKind::Grant,
233237
]
234238
.iter()
235239
.all(|x| Some(x) != prev.as_ref())

0 commit comments

Comments
 (0)