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

An ORDER BY or GROUP BY term that is an integer constant: a request for the result column at that position.

This is a different request from the constant it is written as: SQLite does not evaluate the constant but sorts or groups by the result column it counts to.

Rule: SQLITE-OUTPUT-ORDINAL-001. The constant is one that SQLITE-ORDINAL-001 recognises. A position between 1 and the number of result columns denotes that result column and has its facts; any other position is out of range. When the result columns are not all known, a position beyond the known ones depends on the missing inputs. Source: https://sqlite.org/lang_select.html#the_order_by_clause. Status: Implemented.

Reading the result column an ordinal denotesdoctest
$query = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze("SELECT 'x' AS a, 2 AS b ORDER BY 2");
    $query->facts->scalar($query->statement->orderBy[0]->expression)->resolution->field->name->value // => 'b'
Refusing an expression that is no integer constantdoctest
new \SqlSemantics\Platform\Sqlite\Statement\Query\Ordering\OutputOrdinal(new \SqlSemantics\Platform\Sqlite\Statement\Expression\Literal\TextLiteral('1')) // throws \SqlSemantics\Platform\Sqlite\Model\Diagnostic\InvalidConstruction

Properties§

public Scalar $constant

Methods§

public function __construct(public Scalar $constant)

Parameters

$constantScalarThe integer constant as written
Calls 3
public function position(): int
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the constant and the result column the position denotes among the result columns the environment lists.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the constant.

Parameters

$outOutput
Calls 1

Test cases 10§

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 5

Relations§

Instantiated in 2
Type checks 3