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.

Resolving the parent tabledoctest
$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] // => true

Properties§

public non-empty-list<Name>|null $columns
public list<ReferentialAction> $actions
public QualifiedName $table
public ReferenceMatch|null $match = null

Methods§

public function __construct(
    public QualifiedName $table,
    list<Name>|null $columns = null,
    public ReferenceMatch|null $match = null,
    list<ReferentialAction> $actions = [],
)

Parameters

$tableQualifiedNameThe parent table
$columnslist<Name>|nullThe parent columns; null when no column list is written, otherwise at least one
$matchReferenceMatch|nullThe MATCH clause, when written
$actionslist<ReferentialAction>The ON UPDATE and ON DELETE clauses in written order, at most one per event
Calls 5
public function deriveReferences(
    Derivation $derivation,
    Table|null $defined = null,
    QualifiedName|null $definedName = null,
): RelationFact

Resolves the parent table and records it as a table use.

Parameters

$derivationDerivation
$definedTable|nullThe declaration of the table being defined, which a self reference names
$definedNameQualifiedName|nullThe name the statement defines that table under
Calls 3
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Calls 7

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