classJsonValueCall
final class JsonValueCall
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A call of JSON_VALUE(document, path [RETURNING type] [ON EMPTY] [ON ERROR]) of MySQL 8.0.21 and later.
Rule: MYSQL-JSON-VALUE-001. The value at the path is returned in the RETURNING type, by default VARCHAR(512) in utf8mb4; it is NULL when the document is NULL, when the path finds nothing and by default on an error. The document is a primary expression. Terminates: the parts are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#function_json-value. Status: Implemented.
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT JSON_VALUE('{\"a\": 1}', '$.a' RETURNING SIGNED NULL ON EMPTY)");
$query->field(0)->type->descriptor->name() // => 'SIGNED'Properties§
public Scalar $documentpublic StringLiteral $pathpublic CastTarget|null $returning = nullpublic JsonResponse|null $onEmpty = nullpublic JsonResponse|null $onError = nullMethods§
public function __construct(
public Scalar $document,
public StringLiteral $path,
public CastTarget|null $returning = null,
public JsonResponse|null $onEmpty = null,
public JsonResponse|null $onError = null,
)Parameters
$document | Scalar | The JSON document; a primary expression |
$path | StringLiteral | The path |
$returning | CastTarget|null | The written RETURNING type |
$onEmpty | JsonResponse|null | The ON EMPTY response |
$onError | JsonResponse|null | The ON ERROR response |
Calls 4
- static-call Check::input() line 56
- method-call Precedence::admits() line 56
- new Precedence line 56
- class-const Precedence::SIMPLE_EXPR() line 56
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the parts; the result has the RETURNING type.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 6
- method-call Arguments::one() line 64
- new Arguments line 64
- new ScalarFact line 72
- new Known line 72
- class-const TypeClass::Character() line 72
- class-const Nullability::Nullable() line 72
public function render(Output $out): voidWrites the call.
Parameters
$out | Output |
Test cases 1
Calls 3
- method-call Output::keyword() line 80
- method-call Output::node() line 85
- method-call Output::symbol() line 90
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.