classOrdinaryColumn
final class OrdinaryColumn
implements ColumnSpecification
uses Snapshot
@visibility public.The specification of a column that stores the values written to it: data type, attributes and an inline reference.
Rule: MYSQL-ORDINARY-COLUMN-001. The attributes are kept in written order, because the server applies them in that order (a later NULL cancels an earlier NOT NULL). An inline REFERENCES clause is parsed and ignored by the server; it is kept as a request. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/8.4/en/ansi-diff-foreign-keys.html. Status: Implemented.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE TABLE t (a INT NOT NULL DEFAULT 0)');
count($create->statement->elements[0]->specification->attributes) // => 2Properties§
public list<ColumnAttribute> $attributespublic TypeName $typepublic References|null $references = nullMethods§
public function __construct(
public TypeName $type,
list<ColumnAttribute> $attributes = [],
public References|null $references = null,
)Parameters
$type | TypeName | The data type |
$attributes | list<ColumnAttribute> | The attributes in written order |
$references | References|null | The inline reference, when written |
Calls 2
- static-call Check::listOf() line 46
- class-const ColumnAttribute::class() line 46
public function dataType(): TypeNameAnswers the data type.
Returns
Test cases 1
public function columnAttributes(): list<ColumnAttribute>public function deriveSpecification(Derivation $derivation, Environment $scope): voidDerives the expressions of the attributes inside the table definition.
Parameters
$derivation | Derivation | |
$scope | Environment |
Test cases 1
public function render(Output $out): voidWrites the type, the attributes and the reference.
Parameters
$out | Output |
Calls 1
- method-call Output::node() line 82
Test cases 8§
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 7
ColumnRuleTest::testSpecificationLowersALegacyTypeAndAttributescallsTableDefinitionRulesTest::testColumnSpecificationLowersAFieldDefWithItsReferencecallsColumnSpecificationTest::testColumnAttributesIsDeclaredByTheInterfacecallsColumnSpecificationTest::testDataTypeIsDeclaredByTheInterfacecallsColumnSpecificationTest::testDeriveSpecificationIsDeclaredByTheInterfacecallsColumnSpecificationTest::testImplementationsDeclareTheInterfacecallsReferencesTest::testDeriveReferencesResolvesTheTableBeingDefinedcalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\Column\ColumnRule::specification() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Column/ColumnRule.php:98
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\Column\ColumnRule::specification() packages/sql-semantics-mysql/src/Lowering/TableDefinition/Column/ColumnRule.php:120