UPDATE
and DELETE
requires SELECT
permission
#2423
-
I am sorry if this is a known or intended behavior, but I did find an PR that seemed to have fixed it at one point, and was wondering if this is the intended behavior right now or not. Environment
Description of issuePerforming (Expected behavior vs actual behavior) Users should be able to perform (Steps to reproduce: Include a minimal SQL definition plus how you make the request to PostgREST and the response body)
CREATE POLICY "can update" ON "public"."products"
AS PERMISSIVE FOR UPDATE
TO public
USING (true)
WITH CHECK (true);
CREATE POLICY "can delete" ON "public"."products"
AS PERMISSIVE FOR DELETE
TO public
USING (true)
const { data, error } = await supabase
.from('products')
.update({ name: 'new name' }, { returning: 'minimal' })
.eq('id', 1)
// both data and error are null, but the target row is not deleted
const { data, error } = await supabase
.from('products')
.delete({ returning: 'minimal' })
.eq('id', 1)
console.log(error)
// Fails with status 404
// error: {message: ''} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hm, since you don't have a .eq('id', 1) That means you're not getting any rows to update. Try just selecting the data, you should get zero rows as well. The solution should be creating a Doing it at the SQL level should give you the same results: begin;
set local role anon;
update products set name = 'new name' where id = 1;
UPDATE 0
commit; |
Beta Was this translation helpful? Give feedback.
Hm, since you don't have a
SELECT
policy defined and you do:That means you're not getting any rows to update. Try just selecting the data, you should get zero rows as well.
The solution should be creating a
SELECT
policy.Doing it at the SQL level should give you the same results: