row level security stuck with recursive checking with SELECT
Hi all, I have
rooms
rooms
and
participations
participations
tables. This
participations
participations
has both
room_id
room_id
and
user_id
user_id
. When a user enters a room, a new row is added. You get the idea, right?
I have this function:
create or replace function is_participating(param_room_id uuid)returns boolean as $$ select exists ( select 1 from participations where room_id = param_room_id and user_id = auth.uid() and (role = 'admin' or role = 'user') and status = 'granted' );$$ language sql;
create or replace function is_participating(param_room_id uuid)returns boolean as $$ select exists ( select 1 from participations where room_id = param_room_id and user_id = auth.uid() and (role = 'admin' or role = 'user') and status = 'granted' );$$ language sql;
But when I use this function for
create policy "Can view participations of rooms where they already participate." on participations for select using (is_participating(room_id));
create policy "Can view participations of rooms where they already participate." on participations for select using (is_participating(room_id));
it falls into infinite recursive loop. What's the smart way to deal with this?
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.