© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
7 replies
meg hidey

Upsert not working with Row Level Security

I am trying to setup an upsert for authenticated users. I have setup two row level policies, one is the insert for authenticated users only, the other is an update for authenticated users only. Couldn't get the update for authenticated users only to work, so testing out RLS for anonymous users as well, and I'm still getting the error

"new row violates row-level security policy for table "record""
"new row violates row-level security policy for table "record""


when performing the update. Performing the insert works ok, but the update gives me the error.

My code is

const { error } = await supabase.from("record").upsert(
      [
        {
          masuk: 10,
          keluar: 10,
          stok: 100,
          company_name: "Acme Inc",
          alat_name: "MF 150",
        },
      ],
      {
        onConflict: "masuk,keluar,stok,company_name,alat_name",
      }
    );
const { error } = await supabase.from("record").upsert(
      [
        {
          masuk: 10,
          keluar: 10,
          stok: 100,
          company_name: "Acme Inc",
          alat_name: "MF 150",
        },
      ],
      {
        onConflict: "masuk,keluar,stok,company_name,alat_name",
      }
    );


The RLS for Update is attached
Screenshot_2024-01-05_at_10.24.20_PM.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

upsert() new row violates row-level security policy
SupabaseSSupabase / help-and-questions
4y ago
Help with row level security
SupabaseSSupabase / help-and-questions
12mo ago
ROW LEVEL SECURITY ISSUE
SupabaseSSupabase / help-and-questions
3y ago
RLS Insert working but Upsert throws a 'new row violates row-level security policy 42501' error
SupabaseSSupabase / help-and-questions
4y ago