classIndexElement
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.
$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> $classOptionspublic ColumnKey|ExpressionKey $keypublic DottedName|null $collation = nullpublic DottedName|null $operatorClass = nullpublic SortDirection|null $direction = nullpublic NullsOrder|null $nulls = nullMethods§
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
$key | ColumnKey|ExpressionKey | The column or expression |
$collation | DottedName|null | The collation |
$operatorClass | DottedName|null | The operator class |
$classOptions | list<Definition> | The parameters of the operator class; they need an operator class |
$direction | SortDirection|null | The ordering, when written |
$nulls | NullsOrder|null | The placement of NULL values, when written |
Calls 3
- static-call Check::listOf() line 58
- class-const Definition::class() line 58
- static-call Check::input() line 59
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the key and the operator class parameters.
Parameters
$derivation | Derivation | |
$environment | Environment |
Called from 1
Calls 1
- method-call Derivation::scalar() line 67
public function render(Output $out): voidWrites the key and its options.
Parameters
$out | Output |
Calls 4
- method-call Output::node() line 78
- method-call Output::keyword() line 80
- method-call Writing::definitions() line 83
- new Writing line 83
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
IndexElementTestcalls
Other tests reaching this symbol 1
Relations§
Instantiated in 2
Method calls 1
Constant reads 2
- class-const SqlSemantics\Platform\PostgreSql\Statement\Table\Index\CreateIndex::__construct() packages/sql-semantics-postgres/src/Statement/Table/Index/CreateIndex.php:87
- class-const SqlSemantics\Platform\PostgreSql\Statement\Table\Index\CreateIndex::__construct() packages/sql-semantics-postgres/src/Statement/Table/Index/CreateIndex.php:88
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Table\IndexRule packages/sql-semantics-postgres/src/Lowering/Table/IndexRule.php:181
- type SqlSemantics\Platform\PostgreSql\Lowering\Table\IndexRule packages/sql-semantics-postgres/src/Lowering/Table/IndexRule.php:199
- type SqlSemantics\Platform\PostgreSql\Statement\Constraint\Table\ExclusionElement packages/sql-semantics-postgres/src/Statement/Constraint/Table/ExclusionElement.php:36