classGeneratedColumn
final class GeneratedColumn
implements ColumnSpecification
uses Snapshot
@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.
$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::StoredProperties§
public list<ColumnAttribute> $attributespublic TypeName $typepublic Scalar $expressionpublic CollationName|null $collation = nullpublic GeneratedStorage|null $storage = nullpublic References|null $references = nullMethods§
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
$type | TypeName | The data type |
$expression | Scalar | The generation expression |
$collation | CollationName|null | The collation written before AS |
$storage | GeneratedStorage|null | VIRTUAL or STORED, when written |
$attributes | list<ColumnAttribute> | The attributes in written order |
$references | References|null | The inline reference, when written |
Calls 2
- static-call Check::listOf() line 58
- class-const ColumnAttribute::class() line 58
public function columnAttributes(): list<ColumnAttribute>Answers the attributes in written order.
Returns
list<ColumnAttribute>public function deriveSpecification(Derivation $derivation, Environment $scope): voidDerives the generation expression and the expressions of the attributes inside the table definition.
Parameters
$derivation | Derivation | |
$scope | Environment |
Calls 1
- method-call Derivation::scalar() line 84
public function render(Output $out): voidWrites the type, the collation, the expression, the storage, the attributes and the reference.
Parameters
$out | Output |
Calls 2
- method-call Output::node() line 95
- method-call Output::keyword() line 97
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
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts::references() packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:84
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::column() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:76
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::selected() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:122