There is this table "customer" and it has "is_deleted" column. I did to use it for soft deletetion.
And I set policy like below so that I don't have to add is_deleted = false condition everytime I select or join customer table.
CREATE POLICY "can view customer" ON "public"."customer" USING (((is_deleted = false) AND (EXISTS ( SELECT 1 FROM admin_user WHERE (admin_user.uid = uid())))));
But PATCH request which updates "is_deleted" column doesn't work with this policy.
export const softDeleteCustomer = async(id: number) => {
await supabaseClient.from('customer').update({
is_deleted: true
}).eq('id', id);
}
I get an error saying It's violating row-level security.
{
"code":"42501",
"details":null,
"hint":null,
"message":"new row violates row-level security policy for table \"customer\""
}
So I just removed is_deleted part in policy and it's working. But I don't get it.
What is the problem of it?
What I'm trying to is not to select table but to update table. Why SELECT policy above is preventing updating is_delete column?