classClauseRule
final class ClauseRule
Lowers the clauses of a selection and the clauses written after a query body.
Rule: PG-CLAUSE-LOWER-001. Scope: where_clause, group_clause, group_by_list, group_by_item, empty_grouping_set, rollup_clause, cube_clause, grouping_sets_clause, having_clause, window_clause, window_definition_list, window_definition, opt_sort_clause, sort_clause, sortby_list, sortby, opt_asc_desc, opt_nulls_order. Constructors: SortItem, GroupingSet, WindowDefinition, OutputPosition, SelectOptions. An integer constant written as an ORDER BY, GROUP BY or DISTINCT ON term becomes an OutputPosition (PG-OUTPUT-POSITION-001); in the ORDER BY of an aggregate or a window it stays a constant. Termination: lists are flattened iteratively; grouping sets recurse on the tree depth. Source: https://www.postgresql.org/docs/17/sql-select.html. Status: Implemented.
Methods§
public function options(
Node $sort,
?Node $limit,
?Node $locking,
bool $lockingFirst,
): ?SelectOptionsLowers the ORDER BY, LIMIT and locking clauses written after a query body; none is null.
Returns
Test cases 2
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:146
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:147
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:148
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:150
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:151
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:152
Calls 8
- method-call ClauseRule::sortClause() line 60
- new SortItem line 61
- method-call ClauseRule::positioned() line 61
- class-const OrderingClause::OrderBy() line 61
- method-call LimitRule::limit() line 63
- new LimitRule line 63
- method-call LimitRule::locking() line 64
- new SelectOptions line 69
public function positioned(list<Scalar> $terms, OrderingClause $clause): list<Scalar>Wraps the integer constants among ORDER BY, GROUP BY or DISTINCT ON terms as output positions.
Parameters
$terms | list<Scalar> | |
$clause | OrderingClause |
Returns
list<Scalar>Test cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::options() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:61
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingTerms() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:105
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::distinct() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:251
Calls 3
- method-call Positions::value() line 82
- new Positions line 82
- new OutputPosition line 82
public function groupingTerms(list<Scalar> $terms): list<Scalar|GroupingRow>Reads expressions in a grouping position: a row written without ROW, in any parentheses, is a list of grouping terms, and an integer constant is an output position.
Parameters
$terms | list<Scalar> |
Returns
list<Scalar|GroupingRow>Test cases 2
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingTerms() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:108
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupItems() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:245
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:265
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:266
Calls 5
- class-const RowSpelling::Implicit() line 104
- method-call ClauseRule::positioned() line 105
- class-const OrderingClause::GroupBy() line 105
- new GroupingRow line 108
- method-call ClauseRule::groupingTerms() line 108
Lowers sort_clause, opt_sort_clause or sortby_list without reading positions; no clause is an empty list.
Parameters
$clause | Node |
Returns
list<SortItem>Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 5
- static-call ImplementationGap::production() line 133
- method-call Lowering::items() line 136
- new SortItem line 139
- method-call ClauseRule::nullsOrder() line 139
- method-call ClauseRule::sortDirection() line 140
public function sortDirection(Node $direction): ?SortDirectionLowers opt_asc_desc; no direction is null.
Parameters
$direction | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::sortClause() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:140
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::sortDirection() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:76
Calls 3
- class-const SortDirection::Ascending() line 158
- class-const SortDirection::Descending() line 159
- static-call ImplementationGap::production() line 161
public function nullsOrder(Node $order): ?NullsOrderLowers opt_nulls_order; no clause is null.
Parameters
$order | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::sortClause() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:139
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::sortClause() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:140
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::nullsOrder() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:84
Calls 3
- class-const NullsOrder::First() line 175
- class-const NullsOrder::Last() line 176
- static-call ImplementationGap::production() line 178
Lowers where_clause; no clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 1
- static-call ImplementationGap::production() line 194
Lowers having_clause; no clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 1
- static-call ImplementationGap::production() line 210
public function group(Node $clause): array{SetQuantifier|null, list<Scalar|GroupingRow|GroupingSet>}Lowers group_clause: the quantifier and the items; no clause has neither.
Parameters
$clause | Node |
Returns
array{SetQuantifier|null, list<Scalar|GroupingRow|GroupingSet>}Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 4
- method-call SelectRule::quantifier() line 227
- new SelectRule line 227
- method-call ClauseRule::groupItems() line 227
- static-call ImplementationGap::production() line 228
public function groupItems(Node $list): list<Scalar|GroupingRow|GroupingSet>Lowers group_by_list.
Parameters
$list | Node |
Returns
list<Scalar|GroupingRow|GroupingSet>Throws
ImplementationGap When an item has no ruleTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::group() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:227
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\ClauseRule::groupingSet() packages/sql-semantics-postgres/src/Lowering/Query/ClauseRule.php:267
Calls 4
- method-call Lowering::items() line 242
- method-call ClauseRule::groupingTerms() line 245
- method-call ClauseRule::groupingSet() line 246
- static-call ImplementationGap::production() line 247
public function groupingSet(Node $set): GroupingSetLowers empty_grouping_set, rollup_clause, cube_clause or grouping_sets_clause.
Parameters
$set | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 8
- new GroupingSet line 264
- class-const GroupingSetKind::Empty() line 264
- class-const GroupingSetKind::Rollup() line 265
- method-call ClauseRule::groupingTerms() line 265
- class-const GroupingSetKind::Cube() line 266
- class-const GroupingSetKind::Sets() line 267
- method-call ClauseRule::groupItems() line 267
- static-call ImplementationGap::production() line 268
public function windows(Node $clause): list<WindowDefinition>Lowers window_clause; no clause is an empty list.
Parameters
$clause | Node |
Returns
list<WindowDefinition>Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 3
- static-call ImplementationGap::production() line 286
- method-call Lowering::items() line 289
- new WindowDefinition line 294
Private surface 1§
Implementation details, listed for orientation only.
private Lowering $loweringTest cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 13
ClauseRuleTest::testGroupingSetLowersCubecallsClauseRuleTest::testGroupingTermsFlattensAnImplicitRowInParenthesescallsClauseRuleTest::testGroupingTermsKeepsAnExplicitRowcallsClauseRuleTest::testGroupItemsLowersSetscallsClauseRuleTest::testGroupReadsTheQuantifiercallsClauseRuleTest::testHavingLowersThePredicatecallsClauseRuleTest::testNullsOrderReadsLastcallsClauseRuleTest::testOptionsAnswersNullWithoutClausescallsClauseRuleTest::testPositionedWrapsIntegerConstantscallsClauseRuleTest::testSortClauseKeepsConstantscallsClauseRuleTest::testSortDirectionIsNullWhenNotWrittencallsClauseRuleTest::testWhereIsNullWithoutClausecallsClauseRuleTest::testWindowsLowersTheDefinitionscalls
Other tests reaching this symbol 1
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::sortClause() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:68
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::sortDirection() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:76
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::nullsOrder() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:84
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::where() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:92
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:142
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::selection() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:220
- new SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::distinct() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:251
Method calls 15
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::sortClause() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:68
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::sortDirection() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:76
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::nullsOrder() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:84
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\Queries::where() packages/sql-semantics-postgres/src/Lowering/Query/Queries.php:92
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:146
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:147
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:148
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:150
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:151
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::noParens() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:152
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::selection() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:224
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::selection() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:229
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::selection() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:231
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::selection() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:232
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Query\SelectRule::distinct() packages/sql-semantics-postgres/src/Lowering/Query/SelectRule.php:251