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

A column named by a string literal in a key constraint or an index term.

Rule: SQLITE-LITERAL-COLUMN-001. For compatibility with old databases, SQLite reads a string literal written as a term of a PRIMARY KEY or UNIQUE constraint (under any parentheses and COLLATE clauses) or of CREATE INDEX (under parentheses and at most one COLLATE clause) as an identifier, which must name a column of the table. The literal keeps its spelling; the name is its value. Facts: those of the column the name resolves to in the table being defined or indexed (SQLITE-COLUMN-LOOKUP-001); a name that is no column is a missing column, as "no such column" is for SQLite. A string at any other position, a doubly collated string in an index term included, is the text constant it is. Source: https://sqlite.org/lang_createtable.html#the_primary_key, https://sqlite.org/lang_createindex.html (and sqlite3StringToId() in build.c of the release). Status: Implemented.

Resolving a string key term to the column it namesdoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze("CREATE TABLE t (a INTEGER, PRIMARY KEY ('a'))");
    $term = $create->statement->constraints[0]->items[0]->terms[0]->expression;
    [$term->literal->value, $create->facts->scalar($term)->resolution->slot->column === $create->declarations()[0]->columns[0], $create->declarations()[0]->implicit[0]->column === $create->declarations()[0]->columns[0], $create->toString()] // => ['a', true, true, "CREATE TABLE t (a INTEGER, PRIMARY KEY ('a'))"]

Properties§

public TextLiteral $literal

Methods§

public function __construct(public TextLiteral $literal)

Parameters

$literalTextLiteralThe string literal whose value is the column name
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the facts of the column the name resolves to; the literal itself keeps the facts of the text it spells.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the literal as written.

Parameters

$outOutput
Calls 1

Test cases 7§

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

Dedicated tests 2
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Type checks 5