classConstructRule
final class ConstructRule
Lowers the keyword constructs of simple_expr: CASE, CAST, CONVERT, BINARY and MATCH … AGAINST.
Rule: MYSQL-CONSTRUCT-001. Scope: the simple_expr productions of these constructs and opt_expr, when_list, opt_else, opt_array_cast, opt_interval, ident_list_arg, ident_list, fulltext_options, opt_natural_language_mode, opt_query_expansion. CONVERT(expr, type) is a CAST; the parentheses around the MATCH columns and the words IN NATURAL LANGUAGE MODE are not part of the structure. The WHEN branches are flattened along their list spine. Constructs: CaseExpression, CaseBranch, Cast, CastAtLocal, AtTimeZone, CharsetConversion, BinaryCast, FullTextSearch. Terminates: list spines are flattened in a loop; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/flow-control-functions.html, https://dev.mysql.com/doc/refman/8.4/en/cast-functions.html, https://dev.mysql.com/doc/refman/8.4/en/fulltext-search.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
Lowers one of the constructs.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 12
- new CaseExpression line 64
- method-call ConstructRule::optional() line 64
- method-call Form::node() line 64
- method-call ConstructRule::branches() line 64
- new Cast line 65
- method-call ConstructRule::flag() line 66
- new CastAtLocal line 67
- method-call ConstructRule::zone() line 68
- new CharsetConversion line 69
- new BinaryCast line 70
- method-call ConstructRule::search() line 71
- static-call ImplementationGap::production() line 72
public function zone(Form $form): AtTimeZoneLowers CAST … AT TIME ZONE.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 3
- new AtTimeZone line 83
- method-call Form::node() line 83
- method-call ConstructRule::flag() line 83
Lowers the optional operand of CASE or its ELSE result: a node of opt_expr or opt_else.
Parameters
$optional | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 2
- method-call Lowering::form() line 93
- static-call ImplementationGap::production() line 99
public function branches(Node $list): list<CaseBranch>Lowers the WHEN branches of a CASE expression.
Parameters
$list | Node |
Returns
list<CaseBranch>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 6
- method-call Lowering::form() line 111
- static-call ImplementationGap::production() line 113
- method-call Lists::items() line 115
- new Lists line 115
- function-call
countline 117 - new CaseBranch line 118
public function flag(Node $option): boolLowers the optional ARRAY of a cast or INTERVAL of a time zone: whether the keyword is written.
Parameters
$option | Node |
Returns
boolThrows
ImplementationGap When the production has no ruleTest cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConstructRule::lower() packages/sql-semantics-mysql/src/Lowering/Expression/ConstructRule.php:66
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConstructRule::lower() packages/sql-semantics-mysql/src/Lowering/Expression/ConstructRule.php:67
- method-call SqlSemantics\Platform\MySql\Lowering\Expression\ConstructRule::zone() packages/sql-semantics-mysql/src/Lowering/Expression/ConstructRule.php:83
Calls 2
- method-call Lowering::form() line 131
- static-call ImplementationGap::production() line 136
public function search(Form $form): FullTextSearchLowers MATCH ... AGAINST, keeping whether the column list is parenthesized and whether IN NATURAL LANGUAGE MODE is written.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 7
- method-call Lowering::form() line 147
- method-call Form::node() line 147
- new FullTextSearch line 152
- method-call ConstructRule::columns() line 153
- method-call ConstructRule::mode() line 155
- class-const OptionalWords::Written() line 156
- class-const OptionalWords::Omitted() line 156
Lowers the columns of MATCH: a node of ident_list_arg.
Parameters
$argument | Node |
Returns
list<ColumnUse>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 4
- method-call Lowering::form() line 169
- static-call ImplementationGap::production() line 173
- method-call Lists::items() line 180
- new Lists line 180
public function mode(Node $options): FullTextModeLowers the search mode of AGAINST: a node of fulltext_options.
Parameters
$options | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 5
- method-call Lowering::form() line 194
- class-const FullTextMode::Boolean() line 196
- static-call ImplementationGap::production() line 199
- class-const FullTextMode::NaturalLanguage() line 207
- class-const FullTextMode::QueryExpansion() line 208
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
ConstructRuleTest::testBranchesKeepsTheOrderOfTheWhenBranchescallsConstructRuleTest::testColumnsLowersTheColumnsWithAndWithoutParenthesescallsConstructRuleTest::testFlagTellsWhetherArrayIsWrittencallsConstructRuleTest::testLowerLowersTheKeywordConstructscallsConstructRuleTest::testModeLowersTheSearchModescallsConstructRuleTest::testOptionalLowersTheOperandAndTheElseOfCasecallsConstructRuleTest::testSearchKeepsTheParenthesesAndTheStatedModecallsConstructRuleTest::testZoneLowersTheTimeZoneAndThePrecisioncalls