classSelectRule
final class SelectRule
Lowers query productions into selections, VALUES clauses, compound queries and queries with common tables.
Rule: SQLITE-SELECT-LOWER-001. Scope: select, selectnowith, multiselect_op, oneselect, groupby_opt, having_opt, limit_opt. The arms of a compound query keep their written order; the ORDER BY and LIMIT written after its last arm become those of the compound query. In ORDER BY and GROUP BY an integer constant becomes a result column position (SQLITE-ORDINAL-001). Terminates: the arm list is flattened iteratively; every other child is a strict subtree. Source: https://sqlite.org/lang_select.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function select(Node $select): Select|ValuesClause|Compound|WithQueryLowers a complete query.
Parameters
$select | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalls 3
- method-call SelectRule::body() line 66
- new WithQuery line 67
- static-call ImplementationGap::production() line 69
public function body(Node $body): Select|ValuesClause|CompoundLowers a selectnowith: one arm, or a compound query of its arms in written order.
Parameters
$body | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 3
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::select() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:66
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::select() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:67
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::select() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:68
Calls 11
- method-call SelectRule::arm() line 82
- static-call ImplementationGap::production() line 85
- method-call Lists::items() line 87
- new Lists line 87
- function-call
countline 89 - new CompoundStep line 90
- method-call SelectRule::operator() line 90
- class-const SelectRule::WINDOWED() line 94
- class-const SelectRule::PLAIN() line 95
- new Compound line 96
- method-call SelectRule::limit() line 99
public function operator(Node $operator): CompoundOperatorLowers a multiselect_op.
Parameters
$operator | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 5
- class-const CompoundOperator::Union() line 112
- class-const CompoundOperator::UnionAll() line 113
- static-call CompoundOperator::from() line 114
- function-call
strtoupperline 114 - static-call ImplementationGap::production() line 115
public function arm(Node $arm, bool $ordered): Select|ValuesClauseLowers a oneselect: a selection or a VALUES clause.
Parameters
$arm | Node | |
$ordered | bool | Whether the ORDER BY and LIMIT of a selection stay on it; false for the last arm of a compound query |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 3
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::body() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:82
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::body() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:90
- method-call SqlSemantics\Platform\Sqlite\Lowering\Query\SelectRule::body() packages/sql-semantics-sqlite/src/Lowering/Query/SelectRule.php:92
Calls 4
- class-const SelectRule::PLAIN() line 130
- method-call SelectRule::selection() line 130
- class-const SelectRule::WINDOWED() line 131
- static-call ImplementationGap::production() line 133
Lowers a selection from its clauses.
Parameters
$form | Form | |
$shift | int | The number of positions the WINDOW clause moves the ORDER BY and LIMIT clauses by |
$ordered | bool |
Returns
Called from 2
Calls 5
- new Select line 144
- method-call Form::node() line 145
- method-call SelectRule::groups() line 148
- method-call SelectRule::having() line 149
- method-call SelectRule::limit() line 152
public function groups(Node $clause): list<Scalar>Lowers a groupby_opt: the terms, with integer constants as result column positions.
Parameters
$clause | Node |
Returns
list<Scalar>Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 4
- static-call ImplementationGap::production() line 170
- method-call Ordinals::value() line 174
- new Ordinals line 174
- new OutputOrdinal line 174
Lowers a having_opt: the predicate, or null when the clause is absent.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 1
- static-call ImplementationGap::production() line 192
Lowers a limit_opt: the limit in the spelling written, or null when the clause is absent.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 2
Calls 2
- new Limit line 208
- static-call ImplementationGap::production() line 215
Private surface 3§
Implementation details, listed for orientation only.
private const PLAIN = 'oneselect: SELECT distinct selcollist from where_opt groupby_opt having_opt or…private const WINDOWED = 'oneselect: SELECT distinct selcollist from where_opt groupby_opt having_opt wi…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
SelectRuleTestcalls