classIdentity
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.
$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> $optionspublic GeneratedWhen $whenpublic Name|null $name = nullMethods§
public function __construct(
public GeneratedWhen $when,
list<SequenceOption> $options = [],
public Name|null $name = null,
)Parameters
$when | GeneratedWhen | When the column takes a generated value |
$options | list<SequenceOption> | The options of the sequence |
$name | Name|null | The constraint name |
Calls 2
- static-call Check::listOf() line 47
- class-const SequenceOption::class() line 47
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidDerives the sequence options.
Parameters
$derivation | Derivation | |
$environment | Environment |
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 6
- method-call Writing::constraintName() line 73
- new Writing line 73
- method-call Output::keyword() line 74
- method-call GeneratedWhen::keywords() line 74
- method-call Output::symbol() line 76
- method-call Writing::sequence() line 77
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
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\GeneratedColumns::merged() packages/sql-semantics-postgres/src/Rules/Table/Definition/GeneratedColumns.php:198
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:49
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::conflicts() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:138
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::conflicts() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:152
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::conflicts() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:154
- class-const SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Qualifiers::conflicts() packages/sql-semantics-postgres/src/Rules/Table/Definition/Qualifiers.php:156
Type checks 2
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::notNull() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:182
- instanceof SqlSemantics\Platform\PostgreSql\Statement\Table\Element\ColumnDefinition::deriveClause() packages/sql-semantics-postgres/src/Statement/Table/Element/ColumnDefinition.php:79