Value types
A value type classifies the concrete data a TypeQL query evaluates and stores. Unlike entity, relation, and attribute types, value types are built into the language rather than declared in a schema, and they cannot be subtyped or given capabilities.
Where value types are used
Value types appear in the following contexts.
Attribute value types
Every attribute type is defined with an associated value type using the value keyword, which fixes the value that its attributes carry:
define attribute start-date value date;
The same keyword retrieves attribute types by value type in a pattern, as in match $a value date;.
Literals
A literal written directly in a query is a constant of the value type determined by its syntax: 1 is an integer, 1.0 a double, true a boolean.
Literals supply attribute values on insertion, operands in expressions and comparisons, arguments to function calls, and arguments to value constraints.
Value variables
A variable assigned with let holds a computed value rather than a stored data instance.
Its value type is inferred from the expression that produces it, and is checked when the query is compiled:
match let $x = 1 + 1;
Function signatures
A function declares the type of each argument and each returned element. These may be value types as well as user-defined types:
fun mean-karma($u: user) -> double:
Comparisons
Value types determine which comparisons are legal.
Values may only be compared within a comparable group, and boolean and duration values compare for equality only.
Supported value types
TypeQL provides the following value types.
| Name | TypeQL | Description |
|---|---|---|
|
A logical boolean ( |
|
|
A 64-bit signed integer. |
|
|
A double precision IEEE 754 floating point number. |
|
|
A fixed point signed decimal number. |
|
|
A UTF-8 character string type. |
|
|
An ISO 8601 compliant date type. |
|
|
An ISO 8601 compliant date and time type. |
|
|
An ISO 8601 compliant date and time type with time zone information. |
|
|
An ISO 8601 compliant duration type. |