Genji provides a list of simple data types to store and manipulate data.
|BOOL||Can be either
|INTEGER||Signed integer which takes 1, 2, 4 or 8 bytes depending on the size of the stored number||-9223372036854775808||9223372036854775807|
|DOUBLE||8 bytes decimal||-1.7976931348623157e+308||1.7976931348623157e+308|
|BLOB||Variable size BLOB of data|
|TEXT||Variable size UTF-8 encoded string|
|ARRAY||ARRAY of values of any type|
|DOCUMENT||Object that contains pairs that associate a string field to a value of any type|
The case of NULL
In Genji, NULL is treated as both a value and a type. It represents the absence of data, and is returned in various cases:
- when selecting a field that doesn’t exists
- when selecting a field whose value is NULL
- as the result of the evaluation of an expression
Whenever Genji needs to manipulate data of different types, depending on the situation it will rely on either:
- explicit conversion: The source type and destination type are clearly identified. Ex: When inserting data to field with a constraint or when doing a
- implicit conversion: Two values of different types need to be compared or used by an operator during the evaluation of an expression
Explicit conversion is used when we want to convert a value of a source type into a target type. However, Genji types are not all compatible with one another, and when a user tries to convert them, Genji returns an error. Here is a table describing type compatibility.
|Source type||Target type||Converted||Example|
|DOUBLE||INTEGER||yes, cuts off the decimal part||
|TEXT||BOOL||yes, if the content is a valid boolean||
|TEXT||INTEGER||yes, if the content is a valid integer||
|TEXT||DOUBLE||yes, if the content is a valid decimal number||
|TEXT||BLOB||yes, if the content is a valid base64 value||
|TEXT||ARRAY||yes, if the content is a valid json array||
|TEXT||DOCUMENT||yes, if the content is a valid json object||
|BLOB||TEXT||yes, the content will be encoded in base64|
|ARRAY||TEXT||yes, the content will be encoded as a json array||
|DOCUMENT||TEXT||yes, the content will be encoded as a json object||
There is only one kind of implicit conversion:
DOUBLE. This usually takes place during the evaluation of an expression involving INTEGER and DOUBLE values.
No other conversion is applied unless it’s explicit.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.