Skip to content

Support RLS statements #1404

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

Closed
wyozi opened this issue Aug 28, 2024 · 3 comments · Fixed by #1445
Closed

Support RLS statements #1404

wyozi opened this issue Aug 28, 2024 · 3 comments · Fixed by #1445

Comments

@wyozi
Copy link

wyozi commented Aug 28, 2024

Hey, I'm working on a project where I would like to parse and transform (among others) RLS policy migrations.

Namely, stuff like

create policy "authorize read access"
on "public"."accounting_entries"
as permissive
for select
to public
using (( SELECT authorize_company(accounting_entries.company_id) ));

and

drop policy "Users can update own profile." on "public"."profiles";

Would it be possible to add support for these?

@git-hulk
Copy link
Member

git-hulk commented Sep 8, 2024

@wyozi It would be nice if you can provide the documentation link to which dialect supports this syntax.

@wyozi
Copy link
Author

wyozi commented Sep 8, 2024

Ah of course, this is Postgres dialect. I'm so used to working in the Postgres world that I sometimes forget how different the dialects are 😅

Here's the documentation: https://www.postgresql.org/docs/current/ddl-rowsecurity.html

@git-hulk
Copy link
Member

git-hulk commented Sep 8, 2024

@wyozi Thank you! I will support this when I get time.

git-hulk added a commit to git-hulk/sqlparser-rs that referenced this issue Sep 24, 2024
This PR implements part of feature mentioned in apache#1404.

The following the syntax:

```SQL
CREATE POLICY name ON table_name
    [ AS { PERMISSIVE | RESTRICTIVE } ]
    [ FOR { ALL | SELECT | INSERT | UPDATE | DELETE } ]
    [ TO { role_name | PUBLIC | CURRENT_ROLE | CURRENT_USER | SESSION_USER } [, ...] ]
    [ USING ( using_expression ) ]
    [ WITH CHECK ( check_expression ) ]
```

For the documentation, please refer:

https://www.postgresql.org/docs/current/sql-createpolicy.html
git-hulk added a commit to git-hulk/sqlparser-rs that referenced this issue Sep 26, 2024
```SQL
DROP POLICY [ IF EXISTS ] name ON table_name [ CASCADE | RESTRICT ]
```

For the documentation, please refer:

https://www.postgresql.org/docs/current/sql-createpolicy.html

This closes apache#1404.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants