final class ColumnPart
    implements KeyPart
    uses Snapshot
Public API: explicitly declared with @visibility public.

A key part that names a column, with an optional prefix length and sort direction.

Whether the column exists is checked against the table being defined or indexed (MYSQL-TABLE-PROBLEMS-001). The direction is kept as written; an index is ascending without one. Source: https://dev.mysql.com/doc/refman/8.4/en/create-index.html#create-index-column-prefixes, https://dev.mysql.com/doc/refman/8.4/en/descending-indexes.html.

Reading a prefix key partdoctest
$create = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('CREATE TABLE t (a TEXT, KEY (a(10) DESC))');
    [$create->statement->elements[1]->parts[0]->column->value, $create->statement->elements[1]->parts[0]->length->text] // => ['a', '10']

Properties§

public Name $column
public Numeral|null $length = null
public Direction|null $direction = null

Methods§

public function __construct(
    public Name $column,
    public Numeral|null $length = null,
    public Direction|null $direction = null,
)

Parameters

$columnNameThe column
$lengthNumeral|nullThe prefix length, when written
$directionDirection|nullThe sort direction, when written
public function deriveKeyPart(Derivation $derivation, Environment $scope): void

Derives nothing: a column name is not an expression; the table checks it.

Parameters

$derivationDerivation
$scopeEnvironment
public function render(Output $out): void

Writes the column, the length and the direction.

Parameters

$outOutput
Calls 4

Test cases 3§

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 2

Relations§

Instantiated in 4
Constant reads 1
Type checks 4