How can I achieve this with RLS?
Hi,
I have a table called "studios" and a table called "team_members", which have a studio attached to them.
I want to have a RLS policy to state that only team members can select their own studios that they're a member of, but then I need a RLS policy to select the team_members which are apart of that studio (therefore making me select the studio), causing an infinite loop
I'm now getting a recurrsion error on my RLS policies.
Put simply:
1. I want to select my studio as a team member
2. To do this, I need to check if I'm a team member, so I need to select team_members of the studio
3. To do this, I need access to the studio
4. infinite loop
Policies:
studios SELECT
team_members SELECT:
How can this be resolved so team members can safely select all the studios they are a team member of, and also team members can view all other team members?
1 Reply
You need to move select call in the same table’s select policy to a security definer function to avoid RLS on the select call