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.

Typing JSON_VALUE() with RETURNINGdoctest
$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 $document
public CastTarget|null $returning = null
public JsonResponse|null $onEmpty = null
public JsonResponse|null $onError = null

Methods§

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

$documentScalarThe JSON document; a primary expression
$pathStringLiteralThe path
$returningCastTarget|nullThe written RETURNING type
$onEmptyJsonResponse|nullThe ON EMPTY response
$onErrorJsonResponse|nullThe ON ERROR response
Calls 4
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the parts; the result has the RETURNING type.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 6
public function render(Output $out): void

Writes the call.

Parameters

$outOutput
Test cases 1
Calls 3

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type declarations 1