Skip to content

fix: revoke split #459

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
Jul 16, 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
23 changes: 23 additions & 0 deletions crates/pgt_statement_splitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ mod tests {
}
}

#[test]
fn revoke() {
Tester::from("revoke delete on table \"public\".\"voice_call\" from \"anon\";")
.expect_statements(vec![
"revoke delete on table \"public\".\"voice_call\" from \"anon\";",
]);

Tester::from("revoke select on table \"public\".\"voice_call\" from \"anon\";")
.expect_statements(vec![
"revoke select on table \"public\".\"voice_call\" from \"anon\";",
]);

Tester::from("revoke update on table \"public\".\"voice_call\" from \"anon\";")
.expect_statements(vec![
"revoke update on table \"public\".\"voice_call\" from \"anon\";",
]);

Tester::from("revoke insert on table \"public\".\"voice_call\" from \"anon\";")
.expect_statements(vec![
"revoke insert on table \"public\".\"voice_call\" from \"anon\";",
]);
}

#[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/splitter/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {
SyntaxKind::EXCEPT_KW,
// for grant
SyntaxKind::GRANT_KW,
// for revoke
SyntaxKind::REVOKE_KW,
SyntaxKind::COMMA,
]
.iter()
Expand Down Expand Up @@ -215,6 +217,8 @@ pub(crate) fn unknown(p: &mut Splitter, exclude: &[SyntaxKind]) {
SyntaxKind::INSTEAD_KW,
// for grant
SyntaxKind::GRANT_KW,
// for revoke
SyntaxKind::REVOKE_KW,
SyntaxKind::COMMA,
// Do update in INSERT stmt
SyntaxKind::DO_KW,
Expand Down