classReferences
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.
$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] // => trueProperties§
public list<Name> $columnspublic list<ReferentialAction> $actionspublic QualifiedName $tablepublic KeyMatch|null $match = nullpublic Name|null $name = nullMethods§
public function __construct(
public QualifiedName $table,
list<Name> $columns = [],
public KeyMatch|null $match = null,
list<ReferentialAction> $actions = [],
public Name|null $name = null,
)Parameters
$table | QualifiedName | The referenced table |
$columns | list<Name> | The referenced columns |
$match | KeyMatch|null | The match type, when written |
$actions | list<ReferentialAction> | The ON UPDATE and ON DELETE clauses, in the order written |
$name | Name|null | The constraint name |
Calls 4
- static-call Check::listOf() line 59
- class-const Name::class() line 59
- method-call ForeignKeys::actions() line 60
- new ForeignKeys line 60
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidResolves the referenced table and its columns.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 2
- method-call ForeignKeys::derive() line 76
- new ForeignKeys line 76
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 5
- new Writing line 84
- method-call Writing::constraintName() line 85
- method-call Output::keyword() line 86
- method-call ForeignKeys::writeTarget() line 87
- new ForeignKeys line 87
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
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\GeneratedColumns::columnKeys() packages/sql-semantics-postgres/src/Rules/Table/Definition/GeneratedColumns.php:153
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::attributes() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:111