classTablePrimaryKey
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.
$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> $columnspublic list<Name> $includedpublic list<Definition> $optionspublic list<ConstraintAttribute> $attributespublic Name|null $tablespace = nullpublic Name|null $name = nullMethods§
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
$columns | list<Name> | The key columns; at least one |
$included | list<Name> | The included columns |
$options | list<Definition> | The storage parameters of the index |
$tablespace | Name|null | The tablespace of the index |
$attributes | list<ConstraintAttribute> | The attributes in the order written |
$name | Name|null | The constraint name |
Calls 5
- static-call Check::listOf() line 67
- class-const Name::class() line 67
- class-const Definition::class() line 69
- method-call Attributes::checked() line 70
- new Attributes line 70
public function kind(): ConstraintKindpublic function deriveClause(Derivation $derivation, Environment $environment): voidChecks the columns against the table and derives the parameters.
Parameters
$derivation | Derivation | |
$environment | Environment |
Calls 4
- method-call KeyClauses::derive() line 86
- new KeyClauses line 86
- method-call Attributes::report() line 87
- new Attributes line 87
public function render(Output $out): voidWrites the constraint.
Parameters
$out | Output |
Calls 6
- new Writing line 95
- method-call Writing::constraintName() line 96
- method-call Output::keyword() line 97
- method-call KeyClauses::write() line 98
- new KeyClauses line 98
- method-call Writing::sequence() line 99
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
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Command\Alterations::identity() packages/sql-semantics-postgres/src/Rules/Table/Command/Alterations.php:102
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Declarations::constrain() packages/sql-semantics-postgres/src/Rules/Table/Definition/Declarations.php:167
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Table\Definition\Definitions::report() packages/sql-semantics-postgres/src/Rules/Table/Definition/Definitions.php:168