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.

Reading a unique constraintdoctest
$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> $columns
public list<Name> $included
public list<Definition> $options
public list<ConstraintAttribute> $attributes
public bool|null $nullsDistinct = null
public Name|null $tablespace = null
public Name|null $name = null

Methods§

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

$columnslist<Name>The key columns; at least one
$nullsDistinctbool|nullTrue for NULLS DISTINCT, false for NULLS NOT DISTINCT, null when not written
$includedlist<Name>The included columns
$optionslist<Definition>The storage parameters of the index
$tablespaceName|nullThe tablespace of the index
$attributeslist<ConstraintAttribute>The attributes in the order written
$nameName|nullThe constraint name
Calls 5
public function kind(): ConstraintKind

Answers the kind of the constraint.

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

Checks the columns against the table and derives the parameters.

Parameters

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

Writes the constraint.

Parameters

$outOutput
Calls 7

Test cases 1§

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

Dedicated tests 1

Relations§

Instantiated in 1
Constant reads 1