You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: usage/sync-rules/operators-and-functions.mdx
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@ title: "Operators and Functions"
3
3
description: "Operators and functions can be used to transform columns/fields before being synced to a client."
4
4
---
5
5
6
-
When filtering on parameters (token or [client parameters](/usage/sync-rules/advanced-topics/client-parameters) in the case of [parameter queries](/usage/sync-rules/parameter-queries), and bucket parameters in the case of [data queries](/usage/sync-rules/data-queries)), operators can only be used in a limited way. Typically only `=` , `IN` and `IS NULL` are allowed on the parameters, and special limits apply when combining clauses with `AND`, `OR` or `NOT`. The exact rules are still being refined — make sure to validate and test the Sync Rules.
6
+
When filtering on parameters (token or [client parameters](/usage/sync-rules/advanced-topics/client-parameters) in the case of [parameter queries](/usage/sync-rules/parameter-queries), and bucket parameters in the case of [data queries](/usage/sync-rules/data-queries)), operators can only be used in a limited way. Typically only `=` , `IN` and `IS NULL` are allowed on the parameters, and special limits apply when combining clauses with `AND`, `OR` or `NOT`.
7
7
8
8
When transforming output columns/fields, or filtering on row/document values, those restrictions do not apply.
9
9
@@ -17,32 +17,32 @@ Some fundamental restrictions on these operators and functions are:
| Comparison |\= != < \>\<= \>=| If either parameter is null, this evaluates to null. |
23
-
| Null | IS NULL, IS NOT NULL||
24
-
| Mathematical |+ \-\* / ||
25
-
| Logical | AND, OR, NOT||
26
-
| Cast | CAST(x AS type)<br/>x :: type | Cast to text, numeric, integer, real or blob |
27
-
| JSON | json `->` 'path'<br/> json `->>` 'path' |`->` Returns the value as a JSON string<br/> `->>` Returns the extracted value. |
28
-
| Text concatenation || Joins two text values together. |
29
-
| Arrays |\<left> IN \<right> | Returns true if the left value is present in the right JSON array. In data queries, only the left value |
22
+
| Comparison |`= != < > <= >=`| If either parameter is null, this evaluates to null. |
23
+
| Null |`IS NULL`, `IS NOT NULL`||
24
+
| Mathematical |`+ - * /`||
25
+
| Logical |`AND`, `OR`, `NOT`||
26
+
| Cast |`CAST(x AS type)`<br/>`x :: type`| Cast to text, numeric, integer, real or blob.|
27
+
| JSON |`json -> 'path'`<br/> `json ->> 'path'`|`->` Returns the value as a JSON string.<br/> `->>` Returns the extracted value. |
28
+
| Text concatenation |`\|\|`| Joins two text values together. |
29
+
| Arrays |`<left> IN <right>`| Returns true if the `left` value is present in the `right` JSON array. In data queries, only the `left` value may be a bucket parameter. In parameter queries, the `left` or `right` value may be a bucket parameter. Differs from the SQLite operator in that it can be used directly on a JSON array.|
|[upper(text)](https://www.sqlite.org/lang_corefunc.html#upper)| Convert text to upper case. |
36
36
|[lower(text)](https://www.sqlite.org/lang_corefunc.html#lower)| Convert text to lower case. |
37
-
|[substring(text, start, end)](https://sqlite.org/lang_corefunc.html#substr)| Extracts a portion of a string based on specified starting and ending indexes. |
37
+
|[substring(text, start, length)](https://sqlite.org/lang_corefunc.html#substr)| Extracts a portion of a string based on specified start index and length. Start index is 1-based.|
38
38
|[hex(data)](https://www.sqlite.org/lang_corefunc.html#hex)| Convert blob or text data to hexadecimal text. |
39
39
| base64(data) | Convert blob or text data to base64 text. |
40
40
|[length(data)](https://www.sqlite.org/lang_corefunc.html#length)| For text, return the number of characters. For blob, return the number of bytes. For null, return null. For integer and real, convert to text and return the number of characters. |
41
41
|[typeof(data)](https://www.sqlite.org/lang_corefunc.html#typeof)| text, integer, real, blob or null |
42
-
|[json\_extract(data, path)](https://www.sqlite.org/json1.html#jex)| Same as `->>` operator, but the path must start with $. |
42
+
|[json\_extract(data, path)](https://www.sqlite.org/json1.html#jex)| Same as `->>` operator, but the path must start with `$.`|
43
43
|[json\_array\_length(data)](https://www.sqlite.org/json1.html#jarraylen)| Given a JSON array (as text), returns the length of the array. If data is null, returns null. If the value is not a JSON array, returns 0. |
44
44
|[json\_valid(data)](https://www.sqlite.org/json1.html#jvalid)| Returns 1 if the data can be parsed as JSON, 0 otherwise. |
45
-
| json\_keys(data) | Returns the set of keys as a JSON array. |
45
+
| json\_keys(data) | Returns the set of keys of a JSON object as a JSON array. |
46
46
|[ifnull(x,y)](https://www.sqlite.org/lang_corefunc.html#ifnull)| Returns x if non-null, otherwise returns y. |
47
47
|[unixepoch(datetime, \[modifier\])](https://www.sqlite.org/lang_datefunc.html)| Returns a datetime as Unix timestamp. If modifier is "subsec", the result is a floating point number, with milliseconds including in the fraction. The datetime argument is required - this function cannot be used to get the current time. |
48
48
|[datetime(datetime, \[modifier\])](https://www.sqlite.org/lang_datefunc.html)| Returns a datetime as a datetime string, in the format YYYY-MM-DD HH:MM:SS. If the specifier is "subsec", milliseconds are also included. If the modifier is "unixepoch", the argument is interpreted as a unix timestamp. Both modifiers can be included: datetime(timestamp, 'unixepoch', 'subsec'). The datetime argument is required - this function cannot be used to get the current time. |
0 commit comments