Skip to content
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

[Question] Does Prisma middleware work with Postgres RLS? #2

Open
xinluleo opened this issue Feb 6, 2023 · 0 comments
Open

[Question] Does Prisma middleware work with Postgres RLS? #2

xinluleo opened this issue Feb 6, 2023 · 0 comments

Comments

@xinluleo
Copy link

xinluleo commented Feb 6, 2023

In the prisma client extension example https://github.com/prisma/prisma-client-extensions/tree/main/examples/row-level-security, there's a caveat section saying

NOTE: Because this example extension wraps every query in a new batch transaction, explicitly running transactions with companyPrisma.$transaction() may not work as intended. In a future version of Prisma Client, query extensions will have access to information about whether they are run inside a transaction, similar to the runInTransaction parameter provided to Prisma middleware. When this is available, this example will be updated to work for queries run inside explicit transactions.

Does it mean if I use middleware rather than client extension, then postgres RLS can be supported perfectly by passing a runInTransaction: true parameter, with no change to the rest of the readme instructions? Do you mind providing example code of such a middleware? I also read through the thread prisma/prisma#12735, but didn't get a conclusion to this question. Much appreciated for any help!

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

No branches or pull requests

1 participant