final class ArraySubquery
    implements Scalar, OutputNaming
    uses Snapshot
Public API: explicitly declared with @visibility public.

An array of the values a query returns: ARRAY(SELECT …).

Mirrors PostgreSQL's SubLink node of kind ARRAY_SUBLINK.

Rule: PG-ARRAY-SUBQUERY-001. The query is derived in the environment of the expression and must return one column. Facts: an array of the column's type (an array column gives an array of one more dimension, which has the same type); never NULL, since no row gives an empty array; an unaliased result column is named array. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS. Status: Implemented.

Typing an array subquerydoctest
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT ARRAY(SELECT 1)')->field(0)->type->descriptor->name() // => 'integer[]'

Properties§

public Query $query

Methods§

public function __construct(public Query $query)

Parameters

$queryQueryThe query inside the parentheses
public function outputName(): Name

Names an unaliased result column array.

Returns

Test cases 1
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the query and the array type of its column.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 5
public function render(Output $out): void

Writes ARRAY and the query in parentheses.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 3§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3

Relations§

Instantiated in 1