Im having some problems writing a Row Level Policy...
# sql
l
Im having some problems writing a Row Level Policy for the following: I have a
users
table. A user has an
id
field (foreign key on
auth.oid()
) and also a
company_id
I want to write a RLP such that a user can select the row for any other user provided they are in the same company (i.e have the same
company_id
) I wrote the following statement, but the problem is that I get an infinite recursion error (which makes sense). Anyone know how I would be able to achieve my desired RLP?
Copy code
(id = uid()) OR (company_id = ( SELECT users_1.company_id
   FROM users users_1
  WHERE (users_1.id = uid())
 LIMIT 1)))