classPrimaryRule
final class PrimaryRule
Lowers c_expr, columnref and the indirection steps.
Rule: PG-EXPRESSION-PRIMARY-001. Scope: c_expr (column references, constants, parameters, parenthesized expressions, CASE, function calls, scalar, EXISTS and ARRAY subqueries, array and row constructors, GROUPING), columnref, indirection, opt_indirection, indirection_el and opt_slice_bound. A dotted name followed only by field names is a ColumnReference; one that ends in .* is a ColumnStar; the steps from the first subscript on, or after a .*, make an Indirection of it, as PostgreSQL's makeColumnRef splits them. Function calls go to the invocation family, queries to the query family. Termination: the indirection list is flattened iteratively. Source: https://www.postgresql.org/docs/17/sql-expressions.html. Status: Implemented.
Methods§
Lowers a c_expr.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 13
- method-call PrimaryRule::columnReference() line 63
- method-call Form::node() line 63
- method-call PrimaryRule::parameter() line 65
- method-call PrimaryRule::applied() line 66
- new Grouped line 66
- method-call PrimaryRule::indirection() line 66
- new ScalarSubquery line 69
- new Indirection line 70
- new Exists line 71
- new ArraySubquery line 72
- new ArrayConstructor line 73
- new GroupingFunction line 75
- static-call ImplementationGap::production() line 76
Lowers c_expr: PARAM opt_indirection.
Parameters
$form | Form |
Returns
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::parameter() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:121
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::lower() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:65
Calls 4
- method-call PrimaryRule::applied() line 85
- method-call Form::token() line 85
- method-call PrimaryRule::indirection() line 85
- method-call Form::node() line 85
public function applied(Scalar $base, list<IndirectionStep> $steps): ScalarApplies steps to a value: the value itself when there is none.
Parameters
$base | Scalar | |
$steps | list<IndirectionStep> |
Returns
Test cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::lower() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:66
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::parameter() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:85
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:119
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:122
Calls 1
- new Indirection line 95
Lowers columnref.
Parameters
$reference | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 2
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:93
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::lower() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:63
Calls 7
- method-call PrimaryRule::indirection() line 109
- static-call ImplementationGap::production() line 110
- function-call
countline 113 - function-call
array_sliceline 117 - method-call PrimaryRule::applied() line 119
- new ColumnStar line 119
- new ColumnReference line 122
public function indirection(Node $indirection): list<IndirectionStep>Lowers indirection or opt_indirection; no step is an empty list.
Parameters
$indirection | Node |
Returns
list<IndirectionStep>Throws
ImplementationGap When the list or a step has no ruleTest cases 1
Called from 5
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::indirection() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:105
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::lower() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:66
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::lower() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:70
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::parameter() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:85
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\PrimaryRule::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/PrimaryRule.php:109
Calls 3
- static-call ImplementationGap::production() line 137
- method-call Lowering::items() line 140
- method-call PrimaryRule::step() line 141
public function step(Form $form): IndirectionStepLowers indirection_el.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 2
Called from 1
Calls 7
- new FieldSelection line 155
- method-call Form::node() line 155
- new AllFields line 156
- new Subscript line 157
- new Slice line 158
- method-call PrimaryRule::bound() line 158
- static-call ImplementationGap::production() line 159
Lowers opt_slice_bound; an omitted bound is null.
Parameters
$bound | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 1
- static-call ImplementationGap::production() line 175
Private surface 1§
Implementation details, listed for orientation only.
private Lowering $loweringTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
PrimaryRuleTest::testAppliedKeepsAValueWithoutStepscallsPrimaryRuleTest::testBoundOfAnOmittedBoundIsNullcallsPrimaryRuleTest::testColumnReferenceKeepsAStepAfterAStarcallsPrimaryRuleTest::testColumnReferenceSplitsAtTheFirstSubscriptcallsPrimaryRuleTest::testIndirectionOfNoStepIsEmptycallsPrimaryRuleTest::testLowerLowersGroupingcallsPrimaryRuleTest::testParameterWithoutStepsIsTheParametercallsPrimaryRuleTest::testStepLowersAStarcalls
Relations§
Instantiated in 4
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::expression() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:64
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:93
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::indirection() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:105
- new SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::parameter() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:121
Method calls 4
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::expression() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:64
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::columnReference() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:93
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::indirection() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:105
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Expression\Expressions::parameter() packages/sql-semantics-postgres/src/Lowering/Expression/Expressions.php:121