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

A GENERATED ... AS IDENTITY column constraint: the column takes its values from an implicit sequence.

Mirrors CONSTR_IDENTITY with generated_when and the sequence options. An identity column is implicitly NOT NULL ("the column is implicitly NOT

  • NULL"); its type must be smallint, integer or bigint.

Source: https://www.postgresql.org/docs/17/sql-createtable.html.

An identity column is never NULLdoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a bigint GENERATED ALWAYS AS IDENTITY (START WITH 10))');
    [$create->declarations()[0]->columns[0]->nullability, count($create->statement->definition->elements[0]->qualifiers[0]->options)] // => [\SqlSemantics\Platform\PostgreSql\Model\Statement\Type\Nullability::NotNull, 1]

Properties§

public list<SequenceOption> $options
public Name|null $name = null

Methods§

public function __construct(
    public GeneratedWhen $when,
    list<SequenceOption> $options = [],
    public Name|null $name = null,
)

Parameters

$whenGeneratedWhenWhen the column takes a generated value
$optionslist<SequenceOption>The options of the sequence
$nameName|nullThe constraint name
Calls 2
public function kind(): ConstraintKind

Answers the kind of the constraint.

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

Derives the sequence options.

Parameters

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

Writes the constraint.

Parameters

$outOutput
Calls 6

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 6
Type checks 2