final class TablePrimaryKey
    implements Constraint
    uses Snapshot
Public API: explicitly declared with @visibility public.

A PRIMARY KEY table constraint: the key columns are unique together and never NULL.

Mirrors CONSTR_PRIMARY with keys, including, options, indexspace and the attributes. The key columns of the declaration are NOT NULL. Source: https://www.postgresql.org/docs/17/sql-createtable.html.

The key columns are never NULLdoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a int, b int, PRIMARY KEY (b))');
    [$create->declarations()[0]->columns[0]->nullability, $create->declarations()[0]->columns[1]->nullability] // => [\SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::Nullable, \SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::NotNull]

Properties§

public non-empty-list<Name> $columns
public list<Name> $included
public list<Definition> $options
public list<ConstraintAttribute> $attributes
public Name|null $tablespace = null
public Name|null $name = null

Methods§

public function __construct(
    list<Name> $columns,
    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
$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 6

Test cases 2§

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

Dedicated tests 1
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Constant reads 1
Type checks 3