Hi all, new to supabase, being working with the supabase client and when making an update to a table record which has a RLS policy that only let's owners update their records the record is not updated as expected but i get no error. The response is
I was expecting to get an error indicating that i cannot update the record. Is this the expected behaviour?
Here is the relevant code: table and RLS
CREATE TABLE "public"."user_posts"( id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE, title varchar(255) NOT NULL, body text NOT NULL, created_at timestamp with time zone NOT NULL DEFAULT now(), updated_at timestamp with time zone NOT NULL DEFAULT now());ALTER TABLE public.user_posts ENABLE ROW LEVEL SECURITY;CREATE POLICY "Allow users to create their own posts" ON user_posts FOR INSERT TO authenticated WITH CHECK (( SELECT auth.uid()) = user_id);CREATE POLICY "Allow users to update their own posts" ON user_posts FOR UPDATE TO authenticated USING (( SELECT auth.uid()) = user_id) WITH CHECK (( SELECT auth.uid()) = user_id);
CREATE TABLE "public"."user_posts"( id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE, title varchar(255) NOT NULL, body text NOT NULL, created_at timestamp with time zone NOT NULL DEFAULT now(), updated_at timestamp with time zone NOT NULL DEFAULT now());ALTER TABLE public.user_posts ENABLE ROW LEVEL SECURITY;CREATE POLICY "Allow users to create their own posts" ON user_posts FOR INSERT TO authenticated WITH CHECK (( SELECT auth.uid()) = user_id);CREATE POLICY "Allow users to update their own posts" ON user_posts FOR UPDATE TO authenticated USING (( SELECT auth.uid()) = user_id) WITH CHECK (( SELECT auth.uid()) = user_id);
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.