Skip to content

fix: policies #233

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
Mar 12, 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
6 changes: 6 additions & 0 deletions crates/pglt_statement_splitter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ alter table deal_type add column key text not null;
]);
}

#[test]
fn policy() {
Tester::from("create policy employee_tokenauthed_select on provider_template_approval for select to authenticated, tokenauthed using ( select true );")
.expect_statements(vec!["create policy employee_tokenauthed_select on provider_template_approval for select to authenticated, tokenauthed using ( select true );"]);
}

#[test]
#[timeout(1000)]
fn simple_select() {
Expand Down
4 changes: 4 additions & 0 deletions crates/pglt_statement_splitter/src/parser/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
Some(SyntaxKind::Select) => {
let prev = p.look_back().map(|t| t.kind);
if [
// for policies, with for select
SyntaxKind::For,
// for create view / table as
SyntaxKind::As,
// for create rule
Expand All @@ -149,6 +151,8 @@ pub(crate) fn unknown(p: &mut Parser, exclude: &[SyntaxKind]) {
// for create trigger
SyntaxKind::Before,
SyntaxKind::After,
// for policies, e.g. for insert
SyntaxKind::For,
// e.g. on insert or delete
SyntaxKind::Or,
// for create rule
Expand Down