final class Generated
    implements ColumnConstraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A generated column constraint: the expression that computes the column.

Rule: SQLITE-COLUMN-GENERATED-001. The expression may refer to the other columns of the table and "may not directly reference the ROWID"; it is derived at a position that sees the columns of the table being defined only. A bound parameter, a subquery, a qualified column reference or a non-deterministic function in it is a diagnostic (SQLITE-DEFINITION-LIMITS-001). The keywords GENERATED ALWAYS are optional: the parser reads them as words of the declared type, exactly as SQLite's parser does, and the declared type drops them again (SQLITE-TYPE-RECORDING-001), so the constraint itself writes only AS. The grammar accepts any identifier after the expression; SQLite compares its written text with virtual and stored and rejects every other word, so the word is kept with its quoting and an unknown one is a diagnostic. A column without the word is VIRTUAL. Source: https://sqlite.org/gencol.html. Status: Implemented.

Reading a generated columndoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (a, b GENERATED ALWAYS AS (a + 1) VIRTUAL)');
    [$create->statement->columns[1]->constraints[0]->storage(), $create->toString()] // => [\SqlSemantics\Platform\Sqlite\Statement\Schema\Column\GeneratedStorage::Virtual, 'CREATE TABLE t (a, b GENERATED ALWAYS AS (a + 1) VIRTUAL)']

Properties§

public Scalar $expression
public Word|null $word = null

Methods§

public function __construct(public Scalar $expression, public Word|null $word = null)

Parameters

$expressionScalarThe expression that computes the column
$wordWord|nullThe word written after the expression
Calls 2
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): void

Derives the expression where the columns of the table are visible and reports an unknown storage word.

Parameters

$derivationDerivation
$scopeConstraintScope
Calls 7
public function render(Output $out): void

Writes the clause without the optional GENERATED ALWAYS keywords.

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 3
Other tests reaching this symbol 4

Relations§

Instantiated in 2
Type checks 1
Type declarations 2