classColumnUnique
final class ColumnUnique
implements Constraint
uses Snapshot
Public API: explicitly declared with
@visibility public.A UNIQUE column constraint: no two rows hold the same value in the column.
Mirrors CONSTR_UNIQUE with nulls_not_distinct, options and indexspace. NULLS DISTINCT is the default and is kept when written. Source: https://www.postgresql.org/docs/17/sql-createtable.html.
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int UNIQUE NULLS NOT DISTINCT)');
$create->statement->definition->elements[0]->qualifiers[0]->nullsDistinct // => falseProperties§
public list<Definition> $optionspublic bool|null $nullsDistinct = nullpublic Name|null $tablespace = nullpublic Name|null $name = nullMethods§
public function __construct(
public bool|null $nullsDistinct = null,
list<Definition> $options = [],
public Name|null $tablespace = null,
public Name|null $name = null,
)Parameters
$nullsDistinct | bool|null | True for NULLS DISTINCT, false for NULLS NOT DISTINCT, null when not written |
$options | list<Definition> | The storage parameters of the index |
$tablespace | Name|null | The tablespace of the index |
$name | Name|null | The constraint name |
Calls 2
- static-call Check::listOf() line 47
- class-const Definition::class() line 47
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidDerives the storage parameters.
Parameters
$derivation | Derivation | |
$environment | Environment |
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 5
- new Writing line 73
- method-call Writing::constraintName() line 74
- method-call Output::keyword() line 75
- method-call Writing::nullTreatment() line 76
- method-call Writing::indexParameters() line 77
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.