How to use database function in RLS policy, which return a boolean?

Hello

I have created a function which return true or false based on a user_id and a permission_id, which means it return true if a user has a specific permission.

When running that function in the SQL console it return true. Just for test purposes I have also made a policy which with the specified parameters always should return true, but it does not!

The functions takes a valid permission_id and (for now) a hardcoded user_id (but valid).

I can confirm if I make a policy with a check called true, my RLS policy works, but when using this functions which always return true it doesn't. What am I doing wrong?

Picture 1&2 show two ways I have tried to add the function as a policy (with and without select) and the 3rd shows what the function returns (true).

The last picture shows the policy without select in the policy editor.

What am I missing, why isn't a function which always return true letting me bypass the RLS when a simple true does?
I must be missing something. but what?

Thank you guys!
image.png
image.png
image.png
image.png
Was this page helpful?