classJsonRule
final class JsonRule
Lowers JSON_VALUE and the COLUMNS clause of JSON_TABLE with their ON EMPTY and ON ERROR responses.
Rule: MYSQL-CALL-JSON-001. Scope: the JSON_VALUE alternative of function_call_keyword, opt_returning_type, opt_on_empty_or_error, opt_on_empty_or_error_json_table, on_empty, on_error, json_on_response, columns_clause, columns_list, jt_column, jt_column_type. A JSON_TABLE column may write ON ERROR before ON EMPTY; the order is kept. Constructs: JsonValueCall, JsonResponse, OrdinalityColumn, PathColumn, NestedColumns. Terminates: the column list is flattened in a loop; a nested COLUMNS clause is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#function_json-value, https://dev.mysql.com/doc/refman/8.4/en/json-table-functions.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function value(Form $form): JsonValueCallLowers JSON_VALUE.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 4
- method-call JsonRule::responses() line 55
- method-call Form::node() line 55
- new JsonValueCall line 57
- method-call JsonRule::returning() line 60
public function returning(Node $clause): ?CastTargetLowers the optional RETURNING type: a node of opt_returning_type.
Parameters
$clause | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 2
- method-call Lowering::form() line 73
- static-call ImplementationGap::production() line 78
public function responses(Node $clause): array{JsonResponse|null, JsonResponse|null}Lowers the ON EMPTY and ON ERROR responses: a node of opt_on_empty_or_error.
Parameters
$clause | Node |
Returns
array{JsonResponse|null, JsonResponse|null}Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
Calls 3
- method-call Lowering::form() line 90
- method-call JsonRule::response() line 94
- static-call ImplementationGap::production() line 100
public function response(Node $clause, string $signature): JsonResponseLowers one ON EMPTY or ON ERROR clause.
Parameters
$clause | Node | |
$signature | string | The production the clause must have |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 6
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::responses() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:94
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::responses() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:95
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::responses() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:97
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::responses() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:98
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::path() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:181
- method-call SqlSemantics\Platform\MySql\Lowering\Call\JsonRule::path() packages/sql-semantics-mysql/src/Lowering/Call/JsonRule.php:182
Calls 6
- method-call Lowering::form() line 112
- new JsonResponse line 117
- class-const JsonResponseKind::Error() line 117
- class-const JsonResponseKind::Null() line 118
- class-const JsonResponseKind::Default() line 119
- static-call ImplementationGap::production() line 120
public function columns(Node $clause): list<JsonTableColumn>Lowers the COLUMNS clause of JSON_TABLE: a node of columns_clause.
Parameters
$clause | Node |
Returns
list<JsonTableColumn>Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 2
Calls 4
- method-call Lowering::form() line 132
- method-call Lists::items() line 137
- new Lists line 137
- method-call JsonRule::column() line 138
public function column(Node $column): JsonTableColumnLowers one column: a node of jt_column.
Parameters
$column | Node |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 6
- method-call Lowering::form() line 151
- new OrdinalityColumn line 155
- method-call JsonRule::path() line 156
- new NestedColumns line 157
- method-call JsonRule::columns() line 157
- static-call ImplementationGap::production() line 158
public function path(Form $form): PathColumnLowers a path or EXISTS column.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When a production has no ruleTest cases 1
Called from 1
Calls 6
- method-call Form::node() line 169
- method-call Lowering::form() line 172
- static-call ImplementationGap::production() line 176
- method-call JsonRule::response() line 181
- new PathColumn line 184
- method-call JsonRule::responses() line 187
Private surface 1§
Implementation details, listed for orientation only.
private Lowering $loweringTest cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
JsonRuleTest::testColumnLowersAnOrdinalityColumncallsJsonRuleTest::testColumnsLowersEveryColumnFormcallsJsonRuleTest::testPathKeepsTheReversedOrdercallsJsonRuleTest::testResponseLowersOneClausecallsJsonRuleTest::testResponsesLowersOnErrorcallsJsonRuleTest::testReturningLowersNoTypecallsJsonRuleTest::testValueLowersJsonValuecalls