final class ColumnPrimaryKey
    implements ColumnConstraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A PRIMARY KEY column constraint.

Rule: SQLITE-COLUMN-PRIMARY-KEY-001. The column alone is the primary key of the table. What follows from that (whether the column is the row identifier, whether it can hold NULL) depends on the declared type, the sort order and the table options and is derived by the table definition: a column declared INTEGER PRIMARY KEY DESC is not an alias of the rowid, which is why the sort order is kept even though it does not order anything. Source: https://sqlite.org/lang_createtable.html#the_primary_key, https://sqlite.org/lang_createtable.html#rowid, https://sqlite.org/autoinc.html. Status: Implemented.

Reading a primary key column constraintdoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (id INTEGER PRIMARY KEY ASC ON CONFLICT FAIL AUTOINCREMENT)');
    $key = $create->statement->columns[0]->constraints[0];
    [$key->direction?->value, $key->conflict?->value, $key->autoincrement] // => ['ASC', 'FAIL', true]

Properties§

public SortDirection|null $direction = null
public ConflictResolution|null $conflict = null
public bool $autoincrement = false

Methods§

public function __construct(
    public SortDirection|null $direction = null,
    public ConflictResolution|null $conflict = null,
    public bool $autoincrement = false,
)

Parameters

$directionSortDirection|nullThe written sort order
$conflictConflictResolution|nullThe written ON CONFLICT resolution
$autoincrementboolWhether AUTOINCREMENT is written
public function deriveConstraint(Derivation $derivation, ConstraintScope $scope): void

Derives nothing: the clause has no operand that depends on a declaration.

Parameters

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

Writes the clause.

Parameters

$outOutput
Calls 1

Test cases 5§

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

Dedicated tests 2
Other tests reaching this symbol 3

Relations§

Instantiated in 1
Type checks 2
Type declarations 1