final class ExpressionTarget
    implements Target
    uses Snapshot
Public API: explicitly declared with @visibility public.

A select-list item that is an expression with an optional output name.

Mirrors PostgreSQL's ResTarget with a value. Rule: PG-TARGET-001. The item contributes one field, named by its alias, else by PG-TARGET-NAME-001. Its type and NULL fact are those of the expression, except that an untyped string constant or NULL has type text once the query resolves its output. A t.* or (value).* without an alias expands into the fields it selects (PG-STAR-001); with an alias it is one composite value. Source: https://www.postgresql.org/docs/17/sql-select.html#SQL-SELECT-LIST, https://www.postgresql.org/docs/17/typeconv-select.html. Status: Implemented.

Reading the field of an unnamed constantdoctest
$query = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT 'a'");
    [$query->field(0)->name->value, $query->field(0)->type->descriptor->name()] // => ['?column?', 'text']

Properties§

public Scalar $expression
public Name|null $alias = null

Methods§

public function __construct(public Scalar $expression, public Name|null $alias = null)

Parameters

$expressionScalarThe projected expression
$aliasName|nullThe output name written for it
public function project(Derivation $derivation, Environment $environment, int $position): array

Derives the expression and answers its field, or the fields its star selects.

Parameters

$derivationDerivation
$environmentEnvironment
$positionint

Returns

array
Calls 11
public function render(Output $out): void

Writes the expression and the output name after AS.

Parameters

$outOutput
Calls 3

Test cases 21§

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

Dedicated tests 1
Other tests reaching this symbol 20

Relations§

Instantiated in 3
Type checks 2