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

One key of an index, an exclusion constraint or an ON CONFLICT target: a column or expression with its collation, operator class and ordering.

Mirrors PostgreSQL's IndexElem (name/expr, collation, opclass, opclassopts, ordering, nulls_ordering). The key is derived in the environment of the owner, where the indexed relation is visible. Source: https://www.postgresql.org/docs/17/sql-createindex.html.

Reading the options of an index keydoctest
$index = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE INDEX ON t (a COLLATE "C" text_pattern_ops DESC NULLS LAST)');
    $key = $index->statement->elements[0];
    [$key->collation->last()->value, $key->operatorClass->last()->value, $key->direction, $key->nulls] // => ['C', 'text_pattern_ops', \SqlSemantics\Platform\PostgreSql\Statement\Query\SortDirection::Descending, \SqlSemantics\Platform\PostgreSql\Statement\Query\NullsOrder::Last]

Properties§

public list<Definition> $classOptions
public DottedName|null $collation = null
public DottedName|null $operatorClass = null
public SortDirection|null $direction = null
public NullsOrder|null $nulls = null

Methods§

public function __construct(
    public ColumnKey|ExpressionKey $key,
    public DottedName|null $collation = null,
    public DottedName|null $operatorClass = null,
    list<Definition> $classOptions = [],
    public SortDirection|null $direction = null,
    public NullsOrder|null $nulls = null,
)

Parameters

$keyColumnKey|ExpressionKeyThe column or expression
$collationDottedName|nullThe collation
$operatorClassDottedName|nullThe operator class
$classOptionslist<Definition>The parameters of the operator class; they need an operator class
$directionSortDirection|nullThe ordering, when written
$nullsNullsOrder|nullThe placement of NULL values, when written
Calls 3
public function deriveClause(Derivation $derivation, Environment $environment): void
public function render(Output $out): void

Writes the key and its options.

Parameters

$outOutput
Calls 4

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 2
Method calls 1
Constant reads 2
Type declarations 3