final class ColumnDefinition
    implements Node
    uses Snapshot
Public API: explicitly declared with @visibility public.

One column of a table definition: its name, its declared type and its constraints in written order.

Rule: SQLITE-COLUMN-DEFINITION-001. The declared type is optional and is kept word by word with its quoting, because SQLite records the written text. The constraints are a list in written order; nothing limits how often a kind of constraint occurs. The numbers written as type arguments and the operands of the constraints are derived inside the table definition. Diagnostics: a DEFAULT expression that is not constant (SQLITE-DEFINITION-LIMITS-001), and a DEFAULT on a generated column. Source: https://sqlite.org/syntax/column-def.html, https://sqlite.org/lang_createtable.html#the_default_clause, https://sqlite.org/gencol.html#limitations. Status: Implemented.

Reading a column definitiondoctest
$create = (new \SqlSemantics\Platform\Sqlite\Semantics())->analyze('CREATE TABLE t (price DECIMAL(10, 2) NOT NULL DEFAULT 0)');
    $column = $create->statement->columns[0];
    [$column->name->value, $column->type?->text(), count($column->constraints), $column->notNull()] // => ['price', 'DECIMAL', 2, true]

Properties§

public list<ColumnConstraint> $constraints
public Name $name
public TypeName|null $type = null

Methods§

public function __construct(
    public Name $name,
    public TypeName|null $type = null,
    list<ColumnConstraint> $constraints = [],
)

Parameters

$nameNameThe column name
$typeTypeName|nullThe declared type
$constraintslist<ColumnConstraint>The constraints in written order
Calls 2
public function deriveColumn(Derivation $derivation, ConstraintScope $scope): void
public function render(Output $out): void

Writes the name, the declared type and the constraints.

Parameters

$outOutput
Calls 3

Test cases 7§

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

Dedicated tests 3
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Method calls 6
Constant reads 1
Type declarations 4