final class ResultColumn
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

One projected expression of a selection or of a RETURNING clause with its optional alias.

SQLite names a result column without an alias after the text of its expression from its first token to the start of the next one (SQLITE-RESULT-NAME-001), so such a column keeps that text as a layout (CORE-SPELLING-001): one spelling per token the expression renders, with the comments and whitespace written between them, and the trivia after the expression when it holds a comment. The expression is written in that spelling, so the rendered SQL names the column as the analyzed SQL did. A layout is kept only when it differs from the canonical spelling; a column without one is written in the canonical spelling and is named after it, which is the text the database reads. An aliased column is named by its alias and keeps no layout.

Reading a projected expression, its alias and its spellingdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('SELECT 1 AS one, 1+1');
    [$query->statement->columns[0]->alias?->value, $query->statement->columns[1]->layout?->text(), $query->toString()] // => ['one', '1+1', 'SELECT 1 AS one, 1+1']

Properties§

public Scalar $expression
public Name|null $alias = null
public Layout|null $layout = null
public bool $as = true

Methods§

public function __construct(
    public Scalar $expression,
    public Name|null $alias = null,
    public Layout|null $layout = null,
    public bool $as = true,
)

Parameters

$expressionScalarThe projected expression
$aliasName|nullThe output name
$layoutLayout|nullThe spelling of the expression of a column without an alias when it is not the canonical one
$asboolWhether the keyword AS introduces the alias; SQLite names a column after the text of an expression, which includes it

Throws

InvalidConstruction When AS is left out without an alias, an aliased column has a layout, or the layout does not spell one token per rendered token, keeps whitespace alone after the expression, or is the canonical spelling
Calls 6
public function render(Output $out): void

Writes the expression in its spelling and the alias.

Parameters

$outOutput
Calls 4

Test cases 192§

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

Dedicated tests 11
Other tests reaching this symbol 181

Relations§

Instantiated in 1
Constant reads 6
Type checks 3
Type declarations 8