Jaksa
Jaksa

Reputation: 43

Why is supabase update not working for me?

enter image description here

I am trying to update a user's name in the profiles table. This command works when i disable rls on the table but not when it is on. When the function is called the error is null, data is just an empty array. The user is authenticated by the way.

I tried multiple variations of RLS policy for updating but nothing seemed to have worked. I tried enabling update with auth.uid() = id, setting role to authenticated and a couple of other combinations but nothing works. I am sure it is something with RLS because updating works when I disable RLS. I am using sveltekit by the way and i think the problem might be in the user authentication not being passed to supabase update or something like that

Upvotes: 2

Views: 4733

Answers (1)

Braun Goodson
Braun Goodson

Reputation: 1

I ran into the same issue and found that the problem was using id instead of user_id in my policy condition. If anyone else is stuck, double-check that you’re matching auth.uid() to the correct column (user_id) in your table.

Upvotes: 0

Related Questions