final class References
    implements Constraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A REFERENCES column constraint: a foreign key of one column.

Mirrors CONSTR_FOREIGN with pktable, pk_attrs, fk_matchtype and the actions. The referenced table is resolved (PG-FOREIGN-KEY-001); its facts are the relation facts of this constraint. Source: https://www.postgresql.org/docs/17/sql-createtable.html#SQL-CREATETABLE-PARMS-REFERENCES.

Resolving the referenced tabledoctest
$semantics = new \SqlSemantics\Platform\PostgreSql\Semantics();
    $parent = $semantics->analyze('CREATE TABLE p (id int PRIMARY KEY)');
    $child = $semantics->analyze('CREATE TABLE c (p int REFERENCES p (id) ON DELETE CASCADE)', $parent->declarations());
    $child->facts->relation($child->statement->definition->elements[0]->qualifiers[0])->table->table === $parent->declarations()[0] // => true

Properties§

public list<Name> $columns
public list<ReferentialAction> $actions
public QualifiedName $table
public KeyMatch|null $match = null
public Name|null $name = null

Methods§

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

Parameters

$tableQualifiedNameThe referenced table
$columnslist<Name>The referenced columns
$matchKeyMatch|nullThe match type, when written
$actionslist<ReferentialAction>The ON UPDATE and ON DELETE clauses, in the order written
$nameName|nullThe constraint name
Calls 4
public function kind(): ConstraintKind

Answers the kind of the constraint.

Calls 1
public function deriveClause(Derivation $derivation, Environment $environment): void

Resolves the referenced table and its columns.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the constraint.

Parameters

$outOutput
Calls 5

Test cases 3§

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

Dedicated tests 2
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Constant reads 1
Type checks 2