Permissions Operators
Common operators (all column types except json, jsonb)
| Operator | PostgreSQL equivalent | Description |
|---|---|---|
_eq | = | Equal to |
_ne | <> | Not equal to |
_gt | > | Greater than |
_lt | < | Less than |
_gte | >= | Greater than or equal to |
_lte | <= | Less than or equal to |
_in | IN | In array |
_nin | NOT IN | Not in array |
_is_null | IS NULL | Is null |
Logical operators
| Operator | PostgreSQL equivalent | Description |
|---|---|---|
_and | AND | Logical AND |
_or | OR | Logical OR |
_not | NOT | Logical NOT |
Exists operator
| Operator | PostgreSQL equivalent | Description |
|---|---|---|
_exists | EXISTS | Check for existence |
String extended operators
| Operator | PostgreSQL equivalent | Description |
|---|---|---|
_like | LIKE | Like |
_nlike | NOT LIKE | Not like |
_ilike | ILIKE | Case insensitive like |
_nilike | NOT ILIKE | Case insensitive not like |
_similar | SIMILAR TO | Similar |
_nsimilar | NOT SIMILAR TO | Not similar |
_regex | ~ | Regular expression match |
_iregex | ~* | Case insensitive regex |
_nregex | !~ | Not regex |
_niregex | !~* | Not case insensitive regex |
The SIMILAR TO operator in SQL returns true or false depending on whether its pattern matches the given string. It is much the same as LIKE, except that it interprets the pattern using SQL99's definition of a regular expression. SQL99's regular expressions are a curious cross between LIKE notation and common regular expression notation.
Column comparison operators
| Operator | Description |
|---|---|
_ceq | Column equal to |
_cne | Column not equal to |
_cgt | Column greater than |
_clt | Column less than |
_cgte | Column greater than or equal to |
_clte | Column less than or equal to |
Column comparison operators compare a column with another column of the same type, instead of with a static value or a session variable. The right-hand side names the column to compare with:
"column_name"or["column_name"]refers to a column of the table the expression is evaluated on at that point. At the top level that is the table the permission is defined on; inside a relationship it is the related table.["$", "column_name"]refers to a column of the table the permission is defined on (the root table), also from inside a relationship.
For example, this select permission on an articles table only allows the rows that were updated after they were
published:
{
"updated_at": {
"_cgt": "published_at"
}
}
And this select permission on articles only allows the articles whose author belongs to the same team as the article,
by comparing a column of the related author table with a column of articles itself:
{
"author": {
"team_id": {
"_ceq": ["$", "team_id"]
}
}
}
The two columns must have exactly the same type, so for example an integer column cannot be compared with a bigint
column. Paths through relationships, such as ["$", "author", "team_id"], are not supported on the right-hand side.
Column comparison operators are supported on Postgres-compatible databases and data connectors, but not on SQL Server or BigQuery.
JSONB operators
| Operator | PostgreSQL equivalent | Description |
|---|---|---|
_is_null | IS NULL | Is null |
_contains | @> | Contains (Does the left JSON value contain within it the right value?) |
_contained_in | <@ | Contained in (Is the left JSON value contained within the right value?) |
_has_key | ? | Has key (Does the key/element string exist within the JSON value?) |
_has_keys_any | ?| | Has keys any (Do any of these key/element strings exist?) |
_has_keys_all | ?& | Has keys all (Do all of these key/element strings exist?) |