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

A dotted name used as a value: a request to resolve it as a column at its position.

Mirrors PostgreSQL's ColumnRef node: the parts are kept as written, and which of them name a catalog, a schema, a relation or a column is decided when the reference is resolved.

Rule: PG-COLUMN-REF-001. One part is a column of a visible relation, or else the whole row of a visible relation of that name; where the position offers output columns by name (ORDER BY, GROUP BY), a one-part name that matches one of them refers to it. Two to four parts are a column qualified by relation, schema and catalog, resolved by CORE-COLUMN-LOOKUP-001; a dotted name never selects a field of a composite column, which needs (column).field. Facts: a resolved reference has the type and NULL fact of its slot; a conditional reference depends on its missing inputs; a missing or ambiguous reference, or a name of more than four parts, is invalid. Source: https://www.postgresql.org/docs/17/sql-expressions.html#SQL-EXPRESSIONS-COLUMN-REFS, https://www.postgresql.org/docs/17/rowtypes.html#ROWTYPES-USAGE, https://www.postgresql.org/docs/17/sql-select.html#SQL-ORDERBY. Status: Implemented.

Reading a qualified column referencedoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('SELECT t.a FROM t');
    [count($query->statement->targets[0]->expression->parts), $query->field(0)->name->value] // => [2, 'a']

Properties§

public non-empty-list<Name> $parts

Methods§

public function __construct(list<Name> $parts)

Parameters

$partslist<Name>The parts of the name as written; at least one
Calls 2
public function outputName(): Name

Names an unaliased result column after the last part.

Returns

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

Resolves the reference in the environment and derives its facts.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the parts separated by dots.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 42§

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

Dedicated tests 6
Other tests reaching this symbol 36

Relations§

Instantiated in 2
Type checks 10
Type declarations 1