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

Field selections, subscripts and slices applied to a value: (x).f, $1[2], a[1:2], (SELECT …).f.

Mirrors PostgreSQL's A_Indirection node. The grammar applies steps to a parenthesized expression, a parameter, a scalar subquery, and a column reference once a subscript follows its dotted name; a dotted name that ends in .* is a ColumnStar, which takes further steps only improperly.

Rule: PG-INDIRECTION-001. Facts follow PG-SUBSCRIPT-001. An unaliased result column is named after the last field the steps select, and otherwise as the base names it. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-EXPRESSIONS-SUBSCRIPTS, https://www.postgresql.org/docs/17/sql-expressions.html#FIELD-SELECTION. Status: Implemented.

Selecting a field of a rowdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT (ROW(1, 2)).f2');
    [$query->field(0)->name->value, $query->field(0)->type->descriptor->name()] // => ['f2', 'integer']
Rejecting a field step that the dotted name would absorbdoctest
$a = new \SqlSemantics\Platform\PostgreSql\Statement\Expression\ColumnReference([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('a')]);
    new \SqlSemantics\Platform\PostgreSql\Statement\Expression\Indirection($a, [new \SqlSemantics\Platform\PostgreSql\Statement\Expression\FieldSelection(new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('b'))]) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public non-empty-list<IndirectionStep> $steps
public Scalar $base

Methods§

public function __construct(public Scalar $base, list<IndirectionStep> $steps)

Parameters

$baseScalarThe value the steps apply to
$stepslist<IndirectionStep>The steps in order; at least one
Calls 3
public function outputName(): ?Name

Names an unaliased result column after the last selected field, or as the base does.

Returns

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

Derives the base and the steps, and the value the steps select.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the base and the steps.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 9§

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

Dedicated tests 5
Other tests reaching this symbol 4

Relations§

Instantiated in 2
Type checks 4