classTableUnique
final class TableUnique
implements Constraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A UNIQUE table constraint: no two rows hold the same values in the key columns.
Mirrors CONSTR_UNIQUE with nulls_not_distinct, keys, including, options, indexspace and the attributes. Each key and included column must be a column of the table (PG-KEY-COLUMNS-001). Source: https://www.postgresql.org/docs/17/sql-createtable.html.
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int, b int, UNIQUE NULLS DISTINCT (a) INCLUDE (b) DEFERRABLE)');
$create->toString() // => 'CREATE TABLE t (a INT, b INT, UNIQUE NULLS DISTINCT (a) INCLUDE (b) DEFERRABLE)'Properties§
public non-empty-list<Name> $columnspublic list<Name> $includedpublic list<Definition> $optionspublic list<ConstraintAttribute> $attributespublic bool|null $nullsDistinct = nullpublic Name|null $tablespace = nullpublic Name|null $name = nullMethods§
public function __construct(
list<Name> $columns,
public bool|null $nullsDistinct = null,
list<Name> $included = [],
list<Definition> $options = [],
public Name|null $tablespace = null,
list<ConstraintAttribute> $attributes = [],
public Name|null $name = null,
)Parameters
$columns | list<Name> | The key columns; at least one |
$nullsDistinct | bool|null | True for NULLS DISTINCT, false for NULLS NOT DISTINCT, null when not written |
$included | list<Name> | The included columns |
$options | list<Definition> | The storage parameters of the index |
$tablespace | Name|null | The tablespace of the index |
$attributes | list<ConstraintAttribute> | The attributes in the order written |
$name | Name|null | The constraint name |
Calls 5
- static-call Check::listOf() line 69
- class-const Name::class() line 69
- class-const Definition::class() line 71
- method-call Attributes::checked() line 72
- new Attributes line 72
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidChecks the columns against the table and derives the parameters.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 4
- method-call KeyClauses::derive() line 88
- new KeyClauses line 88
- method-call Attributes::report() line 89
- new Attributes line 89
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 7
- new Writing line 97
- method-call Writing::constraintName() line 98
- method-call Output::keyword() line 99
- method-call Writing::nullTreatment() line 100
- method-call KeyClauses::write() line 101
- new KeyClauses line 101
- method-call Writing::sequence() line 102
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.