classClauseRule
final class ClauseRule
Lowers the filtering, grouping, window and ordering clauses of every grammar generation.
Rule: MYSQL-QUERY-CLAUSES-001. Scope: where_clause, opt_where_clause, having_clause, opt_having_clause, opt_qualify_clause, group_clause, opt_group_clause, group_list, grouping_expr, olap_opt, opt_order_clause, order_clause, order_list, order_expr, order_ident, order_dir, opt_ordering_direction, ordering_direction, opt_window_clause, window_definition_list, window_definition. A clause that writes nothing is absent. Ordering and grouping items keep their written order and direction; in a query ORDER BY or GROUP BY an unsigned integer item is a select list position (MYSQL-ORDINAL-001), elsewhere (windows, GROUP_CONCAT) it is the expression it is. Constructs: Grouping, GroupingModifier, OrderItem, OutputOrdinal, WindowDefinition. Terminates: lists are flattened iteratively. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html, https://dev.mysql.com/doc/refman/8.4/en/group-by-modifiers.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers a WHERE, HAVING or QUALIFY clause; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 11
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:99
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:169
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:171
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:176
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:202
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:204
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:95
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:99
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::where() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:130
Calls 4
- method-call Lowering::form() line 89
- function-call
array_key_existsline 93 - class-const ClauseRule::PREDICATES() line 93
- static-call ImplementationGap::production() line 94
Lowers a GROUP BY clause; an absent clause is null.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:170
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:203
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:96
Calls 8
- method-call Lowering::form() line 108
- new Grouping line 112
- method-call ClauseRule::positions() line 112
- method-call ClauseRule::items() line 112
- method-call ClauseRule::modifier() line 112
- class-const GroupingModifier::Rollup() line 113
- class-const GroupingModifier::Cube() line 114
- static-call ImplementationGap::production() line 115
public function modifier(Node $modifier): ?GroupingModifierLowers the modifier written after a grouping list.
Parameters
$modifier | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 4
- method-call Lowering::form() line 126
- function-call
array_key_existsline 127 - class-const ClauseRule::MODIFIERS() line 127
- static-call ImplementationGap::production() line 128
Lowers the ORDER BY clause of a query, with select list positions; an absent clause is empty.
Parameters
$clause | Node |
Returns
list<OrderItem>Throws
ImplementationGap When a production has no ruleCalled from 7
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:62
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:102
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:174
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:207
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:160
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:117
Calls 2
- method-call ClauseRule::positions() line 142
- method-call ClauseRule::orderItems() line 142
Lowers an ORDER BY clause or an ordering or grouping list as written; an absent clause is empty.
Parameters
$clause | Node |
Returns
list<OrderItem>Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::ordering() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:142
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:142
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::orderItems() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:157
Calls 3
- method-call Lowering::form() line 153
- method-call ClauseRule::orderItems() line 157
- method-call ClauseRule::items() line 158
Lowers the items of an ordering or grouping list in written order.
Parameters
$list | Node |
Returns
list<OrderItem>Throws
ImplementationGap When a production has no ruleCalled from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:112
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:113
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:114
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::orderItems() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:158
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::orderItems() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:159
Calls 7
- method-call Lowering::form() line 171
- class-const ClauseRule::LISTS() line 172
- static-call ImplementationGap::production() line 173
- method-call Lists::items() line 175
- new Lists line 175
- function-call
countline 177 - method-call ClauseRule::item() line 179
Lowers one ordering or grouping item: an order_expr or grouping_expr, or an order_ident with its order_dir.
Returns
Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::orderItem() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::items() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:179
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::items() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:183
Calls 4
- method-call Lowering::form() line 196
- new OrderItem line 199
- method-call ClauseRule::direction() line 199
- static-call ImplementationGap::production() line 201
Lowers a sort direction; no direction is null.
Parameters
$direction | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::direction() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:164
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::item() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:199
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::item() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:200
Calls 4
- method-call Lowering::form() line 212
- function-call
array_key_existsline 216 - class-const ClauseRule::DIRECTIONS() line 216
- static-call ImplementationGap::production() line 217
Answers the items with every unsigned integer read as a select list position.
Parameters
$items | list<OrderItem> |
Returns
list<OrderItem>Test cases 1
Called from 4
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:112
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:113
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::grouping() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:114
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Shared\ClauseRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Shared/ClauseRule.php:142
Calls 3
- class-const NumberForm::Integer() line 234
- new OrderItem line 234
- new OutputOrdinal line 234
public function windows(Node $clause): list<WindowDefinition>Lowers the WINDOW clause; an absent clause is empty.
Parameters
$clause | Node |
Returns
list<WindowDefinition>Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 5
- method-call Lowering::form() line 248
- static-call ImplementationGap::production() line 253
- method-call Lists::items() line 260
- new Lists line 260
- new WindowDefinition line 265
Private surface 5§
Implementation details, listed for orientation only.
private const PREDICATES = ['opt_where_clause:' => null, 'where_clause:' => null, 'opt_where_clause: WHERE…private const DIRECTIONS = ['order_dir:' => null, 'opt_ordering_direction:' => null, 'order_dir: ASC' => \…private const LISTS = ['order_list: order_list , order_ident order_dir' => true, 'order_list: order_i…private const MODIFIERS = ['olap_opt:' => null, 'olap_opt: WITH_CUBE_SYM' => \SqlSemantics\Platform\MySql…private Lowering $loweringTest cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
Relations§
Instantiated in 12
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:62
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:83
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:160
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:194
- new SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:160
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:117
- new SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:87
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::where() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:130
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::ordering() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:142
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::orderItem() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:153
- new SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::direction() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:164
Method calls 26
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::part() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:62
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:99
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::full() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:102
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::into() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:136
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:169
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:170
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:171
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:174
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::from() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:176
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:202
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:203
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:204
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\BlockRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/BlockRule.php:207
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Legacy\UnionRule::ordering() packages/sql-semantics-mysql/src/Lowering/Query/Legacy/UnionRule.php:160
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\ExpressionRule::expression() packages/sql-semantics-mysql/src/Lowering/Query/Modern/ExpressionRule.php:117
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:95
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:96
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Query\Modern\PrimaryRule::specification() packages/sql-semantics-mysql/src/Lowering/Query/Modern/PrimaryRule.php:99
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::where() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:130
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::ordering() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:142
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::orderItem() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:153
- method-call SqlSemantics\Platform\MySql\Lowering\Query\QueryRules::direction() packages/sql-semantics-mysql/src/Lowering/Query/QueryRules.php:164