Tuples

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:

expr.element-index

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.

Examples:

Copy
db> 
SELECT (1, 'EdgeDB').0;
{1}
Copy
db> 
SELECT (number := 1, name := 'EdgeDB').name;
{"EdgeDB"}
Copy
db> 
SELECT (number := 1, name := 'EdgeDB').1;
{"EdgeDB"}

Tuples can be nested:

Copy
db> 
SELECT (nested_tuple := (1, 2),).nested_tuple.0;
{1}

Referencing a non-existent tuple element will result in an error:

Copy
db> 
SELECT (1, 2).5;
EdgeQLError: 5 is not a member of a tuple

---- query context ----

    line 1
        > SELECT (1, 2).3;
Light
Dark
System