-
Notifications
You must be signed in to change notification settings - Fork 0
Compare Values
By default PQL supports the following comparison operators:
-
:
and=
(Equal) -
~
(Like) -
!
and!~
(Not Like) -
!:
and!=
(Not Equal) -
>
(Greater Than) -
<
(Less Than)
The left side of the comparators must always be a field. The right side of the comparator must be one of the following: T_NULL (represented with -
meaning NULL), T_CONSTANT, T_VARIABLE, T_CONSTANTS_ARRAY or T_COMPARE_VALUE.
--- TODO: explain what these are ---
If you do not follow the field name with a comparator it treats it as just the field by itself without having it compared to anything.
###T_CONSTANTS_ARRAY T_CONSTANTS_ARRAY values are unique to comparators because it's shorthand for other operations and each comparator may treat the array of items differently.
Each item in the array list must be a T_CONSTANT, T_COMPARE_VALUE, T_NULL or T_VARIABLE. If the following is given id:[2, 3, 1]
is provided it may output SQL different based on different databases, like: id IN (2, 3, 1)
OR (id = 2 OR id = 3 OR id = 1)
. If id!~["foo", "bar"]is provided it will output something like:
(id NOT LIKE 'foo%' AND id NOT LIKE 'bar%')```
###Some examples
PQL | SQL | Comment |
---|---|---|
id:1 |
id = 1 |
|
id:- |
id IS NULL |
|
id!- |
id NOT LIKE NULL |
|
id=- |
id IS NULL |
|
id:[-,3] |
id IN (NULL, 3) |
|
id~1 |
id LIKE '1%' |
|
id!1 |
id NOT LIKE '1%' |
|
id!:1 |
id != 1 |
|
name:1 |
name = '1' |
|
name!:1 |
name != '1' |
|
name!"foo" |
name NOT LIKE 'foo%' |
|
name ~ "F\"0\\'\n\t" |
name LIKE 'F"\\\'\n\t' |
\n and \t will be treated as new line and tab characters |
name > "jo" |
name > 'jo' |
|
`name``` | name |
|
customer.name:'jo' |
a0.name = 'jo' |
it will auto-join the customer table if able and a0 will represent the linked table |