classTableUnique
final class TableUnique
implements TableConstraint
uses Snapshot
@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.
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (a, b, UNIQUE (a, b))');
count($create->statement->constraints[0]->items[0]->terms) // => 2Properties§
public non-empty-list<SortTerm> $termspublic ConflictResolution|null $conflict = nullMethods§
public function __construct(
list<SortTerm> $terms,
public ConflictResolution|null $conflict = null,
)Parameters
$terms | list<SortTerm> | The key terms in written order; at least one |
$conflict | ConflictResolution|null | The written ON CONFLICT resolution |
Calls 5
- static-call Check::listOf() line 51
- class-const SortTerm::class() line 51
- static-call Check::input() line 53
- method-call KeyTerms::string() line 53
- new KeyTerms line 53
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): voidDerives each term where the columns of the table are visible and reports a term that is no column name.
Parameters
$derivation | Derivation | |
$scope | ConstraintScope |
Calls 6
- method-call Derivation::scalar() line 63
- method-call KeyTerms::reference() line 64
- new KeyTerms line 64
- method-call Derivation::report() line 65
- new PrimaryKeyProblem line 65
- class-const PrimaryKeyFlaw::ExpressionTerm() line 65
public function render(Output $out): voidWrites the clause.
Parameters
$out | Output |
Calls 2
- method-call Output::keyword() line 75
- method-call Output::symbol() line 76
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
KeyTermRuleTest::testKeyTermsWrapAStringUnderAnyParenthesesAndCollationscallsTableConstraintRuleTest::testConstraintLowersEveryKindOfTableConstraintcallsLiteralColumnTest::testDeriveScalarResolvesTheColumnOfTheTableBeingDefinedcallsConstraintRunTest::testRenderWritesTheConstraintsOfARunWithoutCommascalls