Hello guys I need help:
Note that without RLS everything works fine. Also I use Auth to sign in by email or by google.
Error: new row violates row-level security policy for table "notes"
Code: 42501
Hint: null
Details: null
URL:
https://xxxxxx.supabase.co/rest/v1/notes?columns=title%2Ccontent&select=%2A
Headers: [Authorization=[Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6IlFmdnVsMkl....
Koin:
single<SupabaseClient> {
createSupabaseClient(
supabaseUrl = "
https://xxxxx.supabase.co",
supabaseKey = "sb_publishable_xxxxxx"
) {
install(Postgrest)
install(Auth) {
alwaysAutoRefresh = true
autoSaveToStorage = true
autoLoadFromStorage = true
}
}
}
Insert:
supabaseClient.postgrest["notes"].insert(
mapOf(
"title" to title, "content" to content
)
select()
single()
}.decodeAsOrNull()
catch (e: Exception) {
e.printStackTrace()
Log.e("SupabaseDBManager",
"Error inserting note $
{e.localizedMessage}")
null
}
schema:
create table public.notes (
id uuid not null default gen_random_uuid (),
created_at timestamp with time zone not null default now(),
title text not null default ''::text,
content text not null default ''::text,
user_id uuid not null default auth.uid (),
constraint notes_pkey primary key (id),
constraint notes_user_id_fkey foreign KEY (user_id) references auth.users (id) on update CASCADE on delete CASCADE
) TABLESPACE pg_default;