A tuple constructor is an expression that consists of a sequence of comma-separated expressions enclosed in parentheses. It produces a tuple value:
"(" expr [, ... ] ")"
Named tuples are created using the following syntax:
"(" identifier := expr [, ... ] ")"
Note that all elements in a named tuple must have a name.
A tuple constructor automatically creates a corresponding tuple type.
An element of a tuple can be referenced in the form:
Here, expr is any expression that has a tuple type, and element-index is either the zero-based index of the element or the name of an element in a named tuple.
SELECT (1, 'EdgeDB').0;
SELECT (number := 1, name := 'EdgeDB').name;
SELECT (number := 1, name := 'EdgeDB').1;
Tuples can be nested:
SELECT (nested_tuple := (1, 2),).nested_tuple.0;
Referencing a non-existent tuple element will result in an error:
SELECT (1, 2).5;
EdgeQLError: 5 is not a member of a tuple ---- query context ---- line 1 > SELECT (1, 2).3;