classColumnDefinition
final class ColumnDefinition
implements TableElement
uses Snapshot
Public API: explicitly declared with
@visibility public.One column of a table definition: its name and its specification.
Rule: MYSQL-COLUMN-DEFINITION-001. MySQL 5.x lets a table and database qualify the name, which the server requires to name the table of the statement; the qualifier is kept as written. The expressions inside the specification are derived at the position of the table definition (MYSQL-DEFINITION-SCOPE-001). Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/5.7/en/identifier-qualifiers.html. Status: Implemented.
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE TABLE t (id BIGINT UNSIGNED NOT NULL)');
[$create->statement->elements[0]->name->column->value, $create->statement->elements[0]->specification->dataType()->name()] // => ['id', 'BIGINT']Properties§
public ColumnName $namepublic ColumnSpecification $specificationMethods§
public function __construct(public ColumnName $name, public ColumnSpecification $specification)Parameters
$name | ColumnName | The column name, with the qualifier MySQL 5.x allows |
$specification | ColumnSpecification | The type, attributes, generation expression and reference |
public function deriveElement(Derivation $derivation, Environment $scope): voidDerives the expressions of the specification inside the table definition.
Parameters
$derivation | Derivation | |
$scope | Environment |
Calls 1
- method-call ColumnSpecification::deriveSpecification() line 47
public function render(Output $out): voidWrites the name and the specification.
Parameters
$out | Output |
Calls 1
- method-call Output::node() line 55
Test cases 30§
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 29
ElementRuleTest::testElementLowersAColumnWithItsCheckcallsElementRuleTest::testElementsLowersTheElementListcallsTableDefinitionRulesTest::testTableElementLowersAColumncallsColumnFlagsTest::testFlagsAppliesTheAttributesInOrdercallsColumnFlagsTest::testInvisibleFollowsTheLastVisibilityAttributecallsColumnFlagsTest::testNullabilityFollowsTheFlagscallsElementFactsTest::testDeclarationAnswersTheColumnDeclarationcallsElementFactsTest::testReferencesAnswersTheInlineReferencecallsElementFactsTest::testSpecificationDerivesTheExpressionscallsTableDeclarationTest::testColumnDeclaresOneColumnDefinitioncallsTableDeclarationTest::testFindAnswersThePositionOfADefinedColumncallsTableDeclarationTest::testSplitKeepsInvisibleColumnsImplicitcallsCollateAttributeTest::testDeriveAttributeDerivesNothingcallsCommentAttributeTest::testDeriveAttributeDerivesNothingcallsDefaultExpressionTest::testDeriveAttributeResolvesColumnsOfTheTablecallsDefaultLiteralTest::testDeriveAttributeDerivesTheValuecallsEnforcementAttributeTest::testDeriveAttributeDerivesNothingcallsEngineAttributeTest::testDeriveAttributeDerivesNothingcallsFormatAttributeTest::testDeriveAttributeDerivesNothingcallsGeneratedColumnTest::testColumnAttributesAnswersTheAttributescallsGeneratedColumnTest::testDataTypeAnswersTheTypecallsKeywordAttributeTest::testDeriveAttributeDerivesNothingcallsOnUpdateTest::testDeriveAttributeDerivesTheValuecallsOrdinaryColumnTest::testColumnAttributesAnswersTheAttributesInOrdercallsOrdinaryColumnTest::testDataTypeAnswersTheTypecallsSridAttributeTest::testDeriveAttributeDerivesNothingcallsStorageAttributeTest::testDeriveAttributeDerivesNothingcallsReferencesTest::testDeriveReferencesResolvesTheTableBeingDefinedcallsTableElementTest::testImplementationsDeclareTheInterfacecalls
Relations§
Instantiated in 3
- new SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::definition() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:197
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\ElementRule::element() packages/sql-semantics-mysql/src/Lowering/TableDefinition/ElementRule.php:95
- new SqlSemantics\Platform\MySql\Lowering\TableDefinition\ElementRule::column() packages/sql-semantics-mysql/src/Lowering/TableDefinition/ElementRule.php:117
Type checks 6
- instanceof SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule::definition() packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:192
- instanceof SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::command() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:153
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts::element() packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:48
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration::table() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:109
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::report() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:63
- instanceof SqlSemantics\Platform\MySql\Rules\TableDefinition\TableProblems::selected() packages/sql-semantics-mysql/src/Rules/TableDefinition/TableProblems.php:122
Type declarations 8
- type SqlSemantics\Platform\MySql\Lowering\TableChange\Alter\ColumnItemRule packages/sql-semantics-mysql/src/Lowering/TableChange/Alter/ColumnItemRule.php:187
- type SqlSemantics\Platform\MySql\Lowering\TableDefinition\ElementRule packages/sql-semantics-mysql/src/Lowering/TableDefinition/ElementRule.php:111
- type SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:313
- type SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:321
- type SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:74
- type SqlSemantics\Platform\MySql\Rules\TableDefinition\TableDeclaration packages/sql-semantics-mysql/src/Rules/TableDefinition/TableDeclaration.php:72
- type SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumn packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumn.php:36
- type SqlSemantics\Platform\MySql\Statement\Alter\Column\ChangeColumn packages/sql-semantics-mysql/src/Statement/Alter/Column/ChangeColumn.php:41