While I'm very curious to hear how

While I'm very curious to hear how others have tackled this, I will say that RLS is not a great UX for Hyperdrive. There's a lot of impedance mismatch between the sleight-of-hand Hyperdrive uses to achieve its performance and session-level state like RLS. The least-bad version here is probably to use something like SET ROLE myrole; SELECT my_actual_query;. This will disable caching, but Hyperdrive will RESET ALL; after returning the connection to the pool and it'll get you what you're going for without extra locks or round trips. We're still kicking around ideas for how to improve DX here in a way that's more practical.
2 Replies
scook
scook2mo ago
Drizzle ORM - Row-Level Security (RLS)
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
AJR
AJROP2mo ago
No, that still looks like it's using an explicit transaction, instead of just a multi-statement query within a single implicit transaction. Same basic idea, though, just less performant.

Did you find this page helpful?