classElementFacts
final class ElementFacts
Derives the facts inside table elements, column specifications and table options, for CREATE TABLE and ALTER TABLE.
Rule: MYSQL-ELEMENT-FACTS-001. The expressions of an element are derived at the position the caller gives, whose only visible relation is the table being defined or changed (MYSQL-DEFINITION-SCOPE-001). The parent table of a REFERENCES clause is resolved and recorded as a table use (MYSQL-REFERENCES-001). Table options hold no expression and no resolvable name: the tables of a MERGE UNION option are named, not read, when the table is defined. Terminates: one pass over the element. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table.html, https://dev.mysql.com/doc/refman/8.4/en/alter-table.html. Status: Implemented.
Methods§
public function element(
TableElement $element,
Derivation $derivation,
Environment $scope,
Table|null $defined = null,
QualifiedName|null $definedName = null,
): voidDerives an element; a reference to the table being defined resolves to $defined when it is given.
Parameters
$element | TableElement | |
$derivation | Derivation | |
$scope | Environment | |
$defined | Table|null | The declaration the statement provides for the table being defined |
$definedName | QualifiedName|null | The name the statement writes for that table |
Test cases 1
Called from 5
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumn.php:45
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumns::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumns.php:53
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\ChangeColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/ChangeColumn.php:58
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Command\AddConstraint::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Command/AddConstraint.php:44
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTable.php:120
Calls 2
- method-call TableElement::deriveElement() line 47
- method-call ElementFacts::references() line 48
public function specification(
ColumnSpecification $specification,
Derivation $derivation,
Environment $scope,
): voidDerives a column specification held by an ALTER TABLE.
Parameters
$specification | ColumnSpecification | |
$derivation | Derivation | |
$scope | Environment |
Test cases 1
Calls 2
- method-call ColumnSpecification::deriveSpecification() line 57
- method-call ElementFacts::references() line 58
public function options(list<TableOption> $options, Derivation $derivation): voidConfirms a list of table options; they hold nothing to derive.
Parameters
$options | list<TableOption> | |
$derivation | Derivation |
Test cases 1
Called from 1
Calls 2
- static-call Check::listOf() line 68
- class-const TableOption::class() line 68
public function declaration(ColumnDefinition $column): ColumnAnswers the column declaration a column definition requests, as CREATE TABLE declares it without a table-level primary key.
Parameters
$column | ColumnDefinition |
Returns
Test cases 1
Called from 1
Calls 2
- method-call TableDeclaration::column() line 76
- new TableDeclaration line 76
public function references(ColumnSpecification $specification): ?ReferencesAnswers the inline REFERENCES clause of a column specification.
Parameters
$specification | ColumnSpecification |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts::element() packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:48
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts::specification() packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:58
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
ElementFactsTest::testDeclarationAnswersTheColumnDeclarationcallsElementFactsTest::testElementResolvesTheReferencescallsElementFactsTest::testOptionsAcceptsTableOptionscallsElementFactsTest::testReferencesAnswersTheInlineReferencecallsElementFactsTest::testSpecificationDerivesTheExpressionscalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::slot() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:323
- new SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumn.php:45
- new SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumns::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumns.php:53
- new SqlSemantics\Platform\MySql\Statement\Alter\Column\ChangeColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/ChangeColumn.php:58
- new SqlSemantics\Platform\MySql\Statement\Alter\Command\AddConstraint::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Command/AddConstraint.php:44
- new SqlSemantics\Platform\MySql\Statement\Alter\Command\SetTableOptions::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Command/SetTableOptions.php:51
- new SqlSemantics\Platform\MySql\Statement\Table\CreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTable.php:118
Method calls 7
- method-call SqlSemantics\Platform\MySql\Rules\TableChange\ColumnChanges::slot() packages/sql-semantics-mysql/src/Rules/TableChange/ColumnChanges.php:323
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumn.php:45
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\AddColumns::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/AddColumns.php:53
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Column\ChangeColumn::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Column/ChangeColumn.php:58
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Command\AddConstraint::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Command/AddConstraint.php:44
- method-call SqlSemantics\Platform\MySql\Statement\Alter\Command\SetTableOptions::deriveCommand() packages/sql-semantics-mysql/src/Statement/Alter/Command/SetTableOptions.php:51
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTable.php:120