classExpressionKey
final class ExpressionKey
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.An expression as the key of an index, a partition key or extended statistics.
Mirrors the expr of PostgreSQL's IndexElem, PartitionElem and StatsElem. The grammar takes a function call as written and any other expression between parentheses; which of the two is written is kept. The expression is derived where the columns of the relation are visible, and the key has its type and NULL fact. Source: https://www.postgresql.org/docs/17/sql-createindex.html.
$index = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('CREATE INDEX ON t ((a + 1), lower(b))');
[$index->statement->elements[0]->key->parenthesized, $index->statement->elements[1]->key->parenthesized] // => [true, false]new \SqlSemantics\Platform\PostgreSql\Statement\Table\Index\ExpressionKey(new \SqlSemantics\Platform\PostgreSql\Statement\Expression\Predicate\NullTest(new \SqlSemantics\Platform\PostgreSql\Statement\Expression\ColumnReference([new \SqlSemantics\Platform\PostgreSql\Model\Statement\Identifier\Name('a')]), false), false) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstructionProperties§
public Scalar $expressionpublic bool $parenthesized = trueMethods§
public function __construct(public Scalar $expression, public bool $parenthesized = true)Parameters
$expression | Scalar | The expression |
$parenthesized | bool | Whether the expression is written between parentheses; one that is not must be a function call |
Calls 3
- static-call Check::input() line 45
- method-call Precedence::primary() line 46
- new Precedence line 46
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the expression and answers its facts.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 2
- method-call Derivation::scalar() line 56
- new ScalarFact line 58
public function render(Output $out): voidWrites the expression, between parentheses when it is written so.
Parameters
$out | Output |
Calls 2
- method-call Output::symbol() line 67
- method-call Output::node() line 69
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 2
Relations§
Instantiated in 6
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\IndexRule::element() packages/sql-semantics-postgres/src/Lowering/Table/IndexRule.php:186
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\IndexRule::element() packages/sql-semantics-postgres/src/Lowering/Table/IndexRule.php:187
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\MaintenanceRule::statistics() packages/sql-semantics-postgres/src/Lowering/Table/MaintenanceRule.php:81
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\MaintenanceRule::statistics() packages/sql-semantics-postgres/src/Lowering/Table/MaintenanceRule.php:82
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\PartitionRule::element() packages/sql-semantics-postgres/src/Lowering/Table/PartitionRule.php:82
- new SqlSemantics\Platform\PostgreSql\Lowering\Table\PartitionRule::element() packages/sql-semantics-postgres/src/Lowering/Table/PartitionRule.php:83
Type checks 1
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Table\IndexRule packages/sql-semantics-postgres/src/Lowering/Table/IndexRule.php:199
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Index\IndexElement packages/sql-semantics-postgres/src/Statement/Table/Index/IndexElement.php:51
- type SqlSemantics\Platform\PostgreSql\Statement\Table\Partition\PartitionElement packages/sql-semantics-postgres/src/Statement/Table/Partition/PartitionElement.php:37