classAddIdentity
final class AddIdentity
implements AlterCommand
uses Snapshot
Public API: explicitly declared with
@visibility public.ALTER [ COLUMN ] ... ADD GENERATED ... AS IDENTITY: makes a column an identity column.
Mirrors AT_AddIdentity with the sequence options. The column must exist, and its declared type is checked by PG-IDENTITY-TYPE-001. Source: https://www.postgresql.org/docs/17/sql-altertable.html.
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER TABLE t ALTER a ADD GENERATED ALWAYS AS IDENTITY (CACHE 10)');
$statement->toString() // => 'ALTER TABLE t ALTER a ADD GENERATED ALWAYS AS IDENTITY (CACHE 10)'Properties§
public list<SequenceOption> $optionspublic Name $columnpublic GeneratedWhen $whenMethods§
public function __construct(
public Name $column,
public GeneratedWhen $when,
list<SequenceOption> $options = [],
)Parameters
$column | Name | The column |
$when | GeneratedWhen | When the column takes a generated value |
$options | list<SequenceOption> | The options of the sequence; none means no parentheses are written |
Calls 2
- static-call Check::listOf() line 50
- class-const SequenceOption::class() line 50
public function deriveClause(Derivation $derivation, Environment $environment): voidChecks that the column exists and has an identity type, and derives the options.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 6
- method-call Alterations::column() line 58
- new Alterations line 58
- method-call KeyColumns::position() line 60
- new KeyColumns line 60
- method-call IdentityColumns::check() line 63
- new IdentityColumns line 63
public function render(Output $out): voidWrites the action.
Parameters
$out | Output |
Calls 5
- method-call Output::keyword() line 76
- method-call GeneratedWhen::keywords() line 76
- method-call Output::symbol() line 78
- method-call Writing::sequence() line 79
- new Writing line 79
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
AddIdentityTestcalls
Relations§
Instantiated in 1
Type checks 2
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Command\AlterKinds::other() packages/sql-semantics-postgres/src/Rules/Table/Command/AlterKinds.php:159
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Command\Alterations::derive() packages/sql-semantics-postgres/src/Rules/Table/Command/Alterations.php:77