hi all I am getting the error below after creating...
# sql
d
hi all I am getting the error below after creating a policy on my table, the policy is --> columnname in(select samecolumnname from table where user=uid()) the idea is to only select rows for the users that are in the same company as the one logged in "infinite recursion detected in policy for relation \"user_profile\""
b
Can you give a little more info about your problem? What does the relevant table look like? What are the fields?
d
Hi, here are the details user_profile: id company_id - related to companies companies: company_id admin_id - related to user_profile I am creating a policy so that the read will only be allowed if: 1. the current user is the admin of that company 2. if the user_profile row is in the same company as current user
the policy is for user_profile reads
s
@User Using functions with security definer can help bypass "infinite recursion" errors on policies. Example here: https://supabase.io/docs/guides/auth#policies-with-security-definer-functions
d
this is awesome, works like magic..thanks a lot been looking for a solution like this for a long time now