Compares two values for equality. | |
Compares two values for inequality. | |
Compares two (potentially empty) values for equality. | |
Compares two (potentially empty) values for inequality. | |
Less than operator. | |
Greater than operator. | |
Less or equal operator. | |
Greater or equal operator. | |
Returns the number of elements of a given value. | |
Returns true if the given sub-value exists within the given value. | |
Returns the index of a given sub-value in a given value. |
In EdgeQL, any value can be compared to another as long as their types are compatible.
Compares two values for equality.
db>
select 3 = 3.0;
{true}
db>
select 3 = 3.14;
{false}
db>
select [1, 2] = [1, 2];
{true}
db>
select (1, 2) = (x := 1, y := 2);
{true}
db>
select (x := 1, y := 2) = (a := 1, b := 2);
{true}
db>
select 'hello' = 'world';
{false}
Compares two values for inequality.
db>
select 3 != 3.0;
{false}
db>
select 3 != 3.14;
{true}
db>
select [1, 2] != [2, 1];
{false}
db>
select (1, 2) != (x := 1, y := 2);
{false}
db>
select (x := 1, y := 2) != (a := 1, b := 2);
{false}
db>
select 'hello' != 'world';
{true}
Compares two (potentially empty) values for equality.
This works the same as a regular =
operator, but also allows
comparing an empty {}
set. Two empty sets are considered equal.
db>
select {1} ?= {1.0};
{true}
db>
select {1} ?= <int64>{};
{false}
db>
select <int64>{} ?= <int64>{};
{true}
Compares two (potentially empty) values for inequality.
This works the same as a regular =
operator, but also allows
comparing an empty {}
set. Two empty sets are considered equal.
db>
select {2} ?!= {2};
{false}
db>
select {1} ?!= <int64>{};
{true}
db>
select <bool>{} ?!= <bool>{};
{false}
Less than operator.
The operator returns true
if the value of the left expression is less
than the value of the right expression:
db>
select 1 < 2;
{true}
db>
select 2 < 2;
{false}
db>
select 'hello' < 'world';
{true}
db>
select (1, 'hello') < (1, 'world');
{true}
Greater than operator.
The operator returns true
if the value of the left expression is
greater than the value of the right expression:
db>
select 1 > 2;
{false}
db>
select 3 > 2;
{true}
db>
select 'hello' > 'world';
{false}
db>
select (1, 'hello') > (1, 'world');
{false}
Less or equal operator.
The operator returns true
if the value of the left expression is less
than or equal to the value of the right expression:
db>
select 1 <= 2;
{true}
db>
select 2 <= 2;
{true}
db>
select 3 <= 2;
{false}
db>
select 'hello' <= 'world';
{true}
db>
select (1, 'hello') <= (1, 'world');
{true}
Greater or equal operator.
The operator returns true
if the value of the left expression is
greater than or equal to the value of the right expression:
db>
select 1 >= 2;
{false}
db>
select 2 >= 2;
{true}
db>
select 3 >= 2;
{true}
db>
select 'hello' >= 'world';
{false}
db>
select (1, 'hello') >= (1, 'world');
{false}
Returns true if the given sub-value exists within the given value.
When haystack is a str
or a bytes
value,
this function will return true
if it contains needle as a
subsequence within it or false
otherwise:
db>
select contains('qwerty', 'we');
{true}
db>
select contains(b'qwerty', b'42');
{false}
When haystack is an array
, the function will return
true
if the array contains the element specified as needle or
false
otherwise:
db>
select contains([2, 5, 7, 2, 100], 2);
{true}
When haystack is a range, the function will
return true
if it contains either the specified sub-range or element.
The function will return false
otherwise.
db>
select contains(range(1, 10), range(2,5));
{true}
db>
select contains(range(1, 10), range(2,15));
{false}
db>
select contains(range(1, 10), 2);
{true}
db>
select contains(range(1, 10), 10);
{false}
Returns the index of a given sub-value in a given value.
When haystack is a str
or a bytes
value, the
function will return the index of the first occurrence of needle in it.
When haystack is an array
, this will return the index of the
the first occurrence of the element passed as needle. For
array
inputs it is also possible to provide an optional
from_pos argument to specify the position from which to start the
search.
If the needle is not found, return -1
.
db>
select find('qwerty', 'we');
{1}
db>
select find(b'qwerty', b'42');
{-1}
db>
select find([2, 5, 7, 2, 100], 2);
{0}
db>
select find([2, 5, 7, 2, 100], 2, 1);
{3}