classReferences
final class References
implements Node
uses Snapshot
Public API: explicitly declared with
@visibility public.The REFERENCES clause of a foreign key or of a column: the parent table, its columns, MATCH and the referential actions.
Rule: MYSQL-REFERENCES-001. The parent table is a table use: the node records its resolution as a target. A table that refers to itself names the table being defined, which the statement itself declares. At most one action per event; the actions are kept in written order. MATCH is parsed and ignored by InnoDB. Source: https://dev.mysql.com/doc/refman/8.4/en/create-table-foreign-keys.html. Status: Implemented.
$semantics = new \SqlSemantics\Platform\MySql\Semantics();
$parent = $semantics->analyze('CREATE TABLE p (id INT PRIMARY KEY)');
$child = $semantics->analyze('CREATE TABLE c (p INT, FOREIGN KEY (p) REFERENCES p (id) ON DELETE CASCADE)', [$parent]);
$child->facts->relation($child->statement->elements[1]->references)->table->table === $parent->declarations()[0] // => trueProperties§
public non-empty-list<Name>|null $columnspublic list<ReferentialAction> $actionspublic QualifiedName $tablepublic ReferenceMatch|null $match = nullMethods§
public function __construct(
public QualifiedName $table,
list<Name>|null $columns = null,
public ReferenceMatch|null $match = null,
list<ReferentialAction> $actions = [],
)Parameters
$table | QualifiedName | The parent table |
$columns | list<Name>|null | The parent columns; null when no column list is written, otherwise at least one |
$match | ReferenceMatch|null | The MATCH clause, when written |
$actions | list<ReferentialAction> | The ON UPDATE and ON DELETE clauses in written order, at most one per event |
Calls 5
- static-call Check::input() line 58
- static-call Check::listOf() line 59
- class-const Name::class() line 59
- class-const ReferentialAction::class() line 60
- function-call
countline 61
public function deriveReferences(
Derivation $derivation,
Table|null $defined = null,
QualifiedName|null $definedName = null,
): RelationFactResolves the parent table and records it as a table use.
Parameters
$derivation | Derivation | |
$defined | Table|null | The declaration of the table being defined, which a self reference names |
$definedName | QualifiedName|null | The name the statement defines that table under |
Returns
Calls 3
- method-call Derivation::target() line 73
- method-call TableTargets::parent() line 73
- new TableTargets line 73
public function render(Output $out): voidWrites the clause.
Parameters
$out | Output |
Calls 7
- method-call Output::keyword() line 81
- method-call Output::name() line 83
- class-const NameUse::Qualifier() line 83
- class-const NameUse::Relation() line 85
- method-call Output::symbol() line 87
- class-const NameUse::Column() line 92
- method-call Output::node() line 100
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 1
Type declarations 8
- type SqlSemantics\Platform\MySql\Lowering\TableDefinition\Column\ColumnRule packages/sql-semantics-mysql/src/Lowering/TableDefinition/Column/ColumnRule.php:95
- type SqlSemantics\Platform\MySql\Lowering\TableDefinition\ElementRule packages/sql-semantics-mysql/src/Lowering/TableDefinition/ElementRule.php:111
- type SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\ReferenceRule packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/ReferenceRule.php:80
- type SqlSemantics\Platform\MySql\Lowering\TableDefinition\Key\ReferenceRule packages/sql-semantics-mysql/src/Lowering/TableDefinition/Key/ReferenceRule.php:99
- type SqlSemantics\Platform\MySql\Rules\TableDefinition\ElementFacts packages/sql-semantics-mysql/src/Rules/TableDefinition/ElementFacts.php:82
- type SqlSemantics\Platform\MySql\Statement\Table\Column\GeneratedColumn packages/sql-semantics-mysql/src/Statement/Table/Column/GeneratedColumn.php:56
- type SqlSemantics\Platform\MySql\Statement\Table\Column\OrdinaryColumn packages/sql-semantics-mysql/src/Statement/Table/Column/OrdinaryColumn.php:44
- type SqlSemantics\Platform\MySql\Statement\Table\Key\ForeignKey packages/sql-semantics-mysql/src/Statement/Table/Key/ForeignKey.php:44