I have the following enum declaration:
CREATE TYPE known_roles_list AS ENUM ('role1', 'role2')
When the DB executes a certain query, I wish to check if they're doing it with one of these roles, and if not - let the query go through. Something like:
IF current_user NOT IN known_roles_list THEN
RETURN OLD;
END IF;
Obviously, that code above didn't work (raised runtime comparison errors). Nor did unnest()-ing the enum values and searching within them.
How can I make that search - and see if any of the enum's values match the current_user value? (The current_user value is just an example - later, I need to compare these enum values to a row value, denoted by column)
Thanks!