final class GeneratedColumn
    implements ColumnSpecification
    uses Snapshot
Public API: explicitly declared with @visibility public.

The specification of a generated column: its values are computed from an expression (MySQL 5.7 and later).

Rule: MYSQL-GENERATED-COLUMN-001. The expression sees the columns of the table (MYSQL-DEFINITION-SCOPE-001). Without VIRTUAL or STORED the column is VIRTUAL; the storage is kept as written (null when absent). The words GENERATED ALWAYS are optional and change nothing. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table-generated-columns.html. Status: Implemented.

Reading a generated columndoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE TABLE t (a INT, b INT AS (a + 1) STORED)');
    $create->statement->elements[1]->specification->storage // => \SqlSemantics\Platform\MySql\Statement\Table\Column\Kind\GeneratedStorage::Stored

Properties§

public list<ColumnAttribute> $attributes
public TypeName $type
public Scalar $expression
public CollationName|null $collation = null
public GeneratedStorage|null $storage = null
public References|null $references = null

Methods§

public function __construct(
    public TypeName $type,
    public Scalar $expression,
    public CollationName|null $collation = null,
    public GeneratedStorage|null $storage = null,
    list<ColumnAttribute> $attributes = [],
    public References|null $references = null,
)

Parameters

$typeTypeNameThe data type
$expressionScalarThe generation expression
$collationCollationName|nullThe collation written before AS
$storageGeneratedStorage|nullVIRTUAL or STORED, when written
$attributeslist<ColumnAttribute>The attributes in written order
$referencesReferences|nullThe inline reference, when written
Calls 2
public function dataType(): TypeName

Answers the data type.

Returns

public function columnAttributes(): list<ColumnAttribute>

Answers the attributes in written order.

Returns

public function deriveSpecification(Derivation $derivation, Environment $scope): void

Derives the generation expression and the expressions of the attributes inside the table definition.

Parameters

$derivationDerivation
$scopeEnvironment
Calls 1
public function render(Output $out): void

Writes the type, the collation, the expression, the storage, the attributes and the reference.

Parameters

$outOutput
Calls 2

Test cases 3§

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 2

Relations§

Instantiated in 1
Type checks 3