DELETE doesn't seem to work with RLS turned on in ...
# help
m
DELETE doesn't seem to work with RLS turned on in combination with having SELECT locked down. Even when the DELETE policy is hard set to
true
. Has anyone noticed this? Works fine if I turn RLS off.
returning: 'minimal'
doesn't have any affect. The returned status is 204. No RLS errors at all. 🤔
b
Can you show your code for doing the DELETE?
f
This can be the case because it also selects data before delete, to return it. Could you share an example?
b
He said he was using
{ returning: "minimal" }
though which should solve that.
m
Copy code
const deleting = await supabase
    .from('connected_stores_keys')
    .delete({
      returning: 'minimal'
    })
    .eq('store_id', store_id);
Insert works well with
{ returning: "minimal" }
, but delete doesn't seem to work
If I return the full response without returning minimal I don't get any errors.
Copy code
{
  "error": null,
  "data": [],
  "count": null,
  "status": 200,
  "statusText": "",
  "body": []
}
The status is 204 with minimal.
Thank you for looking at this 😊
Am I using returning minimal in the right way with delete? It works If I do add a
SELECT
policy
b
@User I'm asking the team about this because I can't seem to find any examples of this anywhere. I'll let you know what I find.
@User has verified that this code should work
.delete({returning: 'minimal'})
so you're doing it right.
Ok, here's the issue:
From Bobbie: The problem is you can't use filters with delete with SELECT locked down: https://www.postgresql.org/docs/current/sql-createpolicy.html#RLS-SELECT-PRIV You need
SELECT
visibility to do a
WHERE
with columns So for his case
SELECT
with
uid() = user_id
should do it
m
@User I see! Thank you for checking on this and adding the note to the docs. I'll have to move the code to server functions instead, as I do need
SELECT
to remain locked. Thank you again! 😊