supabase-wrote: know when an update or delete did not save, and why #51530
Replies: 2 comments 3 replies
|
Nice — this solves a real gap: One more silent case worth folding into UPDATE with a The catalog query that catches both: select tablename, policyname, cmd, qual, with_check
from pg_policies
where schemaname = 'public' and cmd in ('UPDATE', 'INSERT')
order by tablename;Any UPDATE row with Worth cross-linking: I maintain the symptom-index side of this family (fix-by-symptom map: https://dev.to/cekuu35/rls-not-working-fix-by-symptom-a-debugging-map-for-supabase-4gj9 ) — if you ever want to point Good call shipping it as a lint ( |
|
I'm building Rewind for recovery of captured Supabase updates. One documentation addition I'd suggest: A disposable test case:
Every writer must advance the revision for this contract to hold. The empty result alone cannot distinguish stale revision, missing row and RLS filtering. I'd keep the generic This is a proposed test case, not a claim that I've run your package. PostgreSQL's Read Committed documentation explains the WHERE recheck behind it. |
Uh oh!
There was an error while loading. Please reload this page.
When row level security blocks an update or delete, Postgres matches no rows and supabase-js returns
{ error: null }.My app said Saved on a task, but nothing was actually saved.
So I made one package with three parts:
wrote(result): returns the saved rows, or throws with the reason.npx supabase-wrote find .: lists updates and deletes that cannot tell whether they saved, and fails CI on new ones.policies.sql: a read-only check that lists tables where updates silently do nothing, usually an UPDATE policy with no SELECT policy.Tested against real Postgres and PostgREST.
https://github.com/lagudafuadtosin/supabase-wrote
npm: supabase-wrote
MIT. If it gets something wrong, let me know and I will fix it.
All reactions