🎸
🚀 Beta Running
PYNGUP: Rebellion against toxic productivity
Beta limited to 100 spots. Tasks become social commitments instead of lonely to-dos.
I was confronted with a Supabase problem that (almost) drove me crazy: I have a simple table "projects" that only stores a project uuid and a project name. While developing on my Web-App I disabled role level security (RLS) for this table. I usually proceed disabling row level policies in the first phase of developing as it helps me to focus on the frontend and the general project scheme.
As I enabled row-level security on my "projects" table and trying to insert new data I received the following error:
new row violates row-level security policy for table "projects"
This is how my policy looks like:

This is a simple rule that checks if the user is authenticated while inserting new data. I took the rule from the example rules provided by the Supabase Team itself.
I found out that Supabase (or Postgres?) seems to not only INSERT the data you provide but also directly tries to SELECT it. So if you don't have a SELECT policy also the INSERT process fails.
In my case this is not quite easy to solve: I have another table called project_members where I reference all users that are related to the project. So at first time when inserting new data to the projects table there is no data in the project_members table. This leads to a situation where the SELECT policy for my projects table always fails on the first INSERT.
But fortunately there is another way:
Just add { returning: 'minimal' } to your insert statement. This suppresses the direct selection of the added data. The complete statement looks like this:
await supabase.from('sample').insert({ key: 'value' }, { returning: 'minimal' })
This works perfectly!
Nikolai Fischer is the founder of Kommune3 (since 2007) and a leading expert in Drupal development and tech entrepreneurship. With 17+ years of experience, he has led hundreds of projects and achieved #1 on Hacker News. As host of the "Kommit mich" podcast and founder of skillution, he combines technical expertise with entrepreneurial thinking. His articles about Supabase, modern web development, and systematic problem-solving have influenced thousands of developers worldwide.
Comments2
Thanks !!
This bug drives me crazy too and I spent a lot of time before discovering your article !
Nice job ! Thank you !!
Thanks😊
This worked perfectly