final class TableUnique
    implements TableConstraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A UNIQUE table constraint.

Rule: SQLITE-TABLE-UNIQUE-001. The grammar writes the key terms as ordering terms, so any expression parses; SQLite accepts column names only, each optionally with a collation and a sort order ("expressions prohibited in

  • PRIMARY KEY and UNIQUE constraints"). A column name is an identifier, a

double-quoted word or a string literal (LiteralColumn; a plain string literal term is refused at construction, SQLITE-KEY-TERM-001). Each term is derived where the columns and the row identifier of the table are visible. Source: https://sqlite.org/lang_createtable.html#unique_constraints. Status: Implemented.

Reading the terms of a unique constraintdoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (a, b, UNIQUE (a, b))');
    count($create->statement->constraints[0]->items[0]->terms) // => 2

Properties§

public non-empty-list<SortTerm> $terms
public ConflictResolution|null $conflict = null

Methods§

public function __construct(
    list<SortTerm> $terms,
    public ConflictResolution|null $conflict = null,
)

Parameters

$termslist<SortTerm>The key terms in written order; at least one
$conflictConflictResolution|nullThe written ON CONFLICT resolution
Calls 5
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): void

Derives each term where the columns of the table are visible and reports a term that is no column name.

Parameters

$derivationDerivation
$scopeConstraintScope
Calls 6
public function render(Output $out): void

Writes the clause.

Parameters

$outOutput
Calls 2

Test cases 7§

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

Dedicated tests 3
Other tests reaching this symbol 4

Relations§

Instantiated in 1