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

The definition of one column: its name, type, storage, compression, foreign-data options and constraints.

Mirrors PostgreSQL's ColumnDef with the constraint list ColQualList builds. The qualifiers are kept in the order written: constraints, deferral attributes (which apply to the constraint before them) and a collation. Their problems are reported by PG-COLUMN-QUALIFIERS-001; their expressions are derived in the environment of the table; the type of an identity column is checked by PG-IDENTITY-TYPE-001. Source: https://www.postgresql.org/docs/17/sql-createtable.html.

Reading a column definitiondoctest
$create = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE TABLE t (a text STORAGE external COMPRESSION lz4 COLLATE "C" NOT NULL)');
    $column = $create->statement->definition->elements[0];
    [$column->name->value, $column->storage->method->value, $column->compression->method->value, count($column->qualifiers)] // => ['a', 'external', 'lz4', 2]

Properties§

public list<GenericOption> $options
public list<Clause> $qualifiers
public Name $name
public TypeName $type
public ColumnStorage|null $storage = null
public ColumnCompression|null $compression = null

Methods§

public function __construct(
    public Name $name,
    public TypeName $type,
    public ColumnStorage|null $storage = null,
    public ColumnCompression|null $compression = null,
    list<GenericOption> $options = [],
    list<Clause> $qualifiers = [],
)

Parameters

$nameNameThe column name
$typeTypeNameThe data type
$storageColumnStorage|nullThe STORAGE clause
$compressionColumnCompression|nullThe COMPRESSION clause
$optionslist<GenericOption>The foreign-data options
$qualifierslist<Clause>The constraints, deferral attributes and collation, in the order written
Calls 4
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the type and the qualifiers in the environment of the table and reports their problems.

Parameters

$derivationDerivation
$environmentEnvironment
Called from 1
Calls 8
public function render(Output $out): void

Writes the column definition.

Parameters

$outOutput
Calls 3

Test cases 14§

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 13

Relations§

Instantiated in 1
Method calls 1
Type checks 6
Type declarations 2