final class ForeignKeyClause
    implements ColumnConstraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A REFERENCES clause: the parent table of a foreign key, its key columns and the actions.

Rule: SQLITE-FK-CLAUSE-001. Written as a column constraint, the clause makes the column a foreign key of one column. The parent is named without a schema and belongs to the schema of the child table. SQLite does not look the parent up when the table is defined ("the parent table or parent key

  • columns do not exist" is found when rows are changed), so the model records

no resolution and no diagnostic for the parent. A parent column written with a collation or a sort order is a syntax error in SQLite and is reported as a diagnostic. Source: https://sqlite.org/foreignkeys.html, https://sqlite.org/syntax/foreign-key-clause.html. Status: Implemented.

Reading the parent of a foreign keydoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE c (p REFERENCES parent (id) ON DELETE CASCADE)');
    $clause = $create->statement->columns[0]->constraints[0];
    [$clause->table->value, $clause->columns[0]->name->value, count($clause->arguments)] // => ['parent', 'id', 1]

Properties§

public list<ListedColumn>|null $columns
public list<ReferenceArgument> $arguments
public Name $table

Methods§

public function __construct(
    public Name $table,
    list<ListedColumn>|null $columns = null,
    list<ReferenceArgument> $arguments = [],
)

Parameters

$tableNameThe parent table
$columnslist<ListedColumn>|nullThe parent key columns; null when none are written, otherwise at least one
$argumentslist<ReferenceArgument>The actions and MATCH names in written order
Calls 3
public function reaction(ReferenceEvent $event): ReferenceReaction

Answers the reaction in effect for an event: that of the last action written for it, or no action.

Parameters

Test cases 2
Calls 1
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): void
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Calls 4

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Method calls 1
Type declarations 2