final class JsonExtraction
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A JSON path extraction from a column: col->'path', which is JSON_EXTRACT(col, 'path'), or col->>'path', which is JSON_UNQUOTE(JSON_EXTRACT(col, 'path')) (MySQL 5.7 and later).

Rule: MYSQL-JSON-EXTRACTION-001. Facts: -> yields a JSON value and ->> a LONGTEXT; both are NULL when the path selects nothing, so they can always be NULL. Terminates: the column is a strict part. Source: https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_json-column-path, https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_json-inline-path. Status: Implemented.

Reading the path of an unquoting extractiondoctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT a FROM t WHERE a->>'$.b' = 'x'");
    [$query->statement->where->left->path->value, $query->statement->where->left->unquote] // => ['$.b', true]

Properties§

public ColumnUse $column
public Text $path
public bool $unquote = false

Methods§

public function __construct(
    public ColumnUse $column,
    public Text $path,
    public bool $unquote = false,
)

Parameters

$columnColumnUseThe JSON column
$pathTextThe JSON path
$unquoteboolWhether the result is unquoted (`->>`)
Calls 1
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the column; the result is JSON or text.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the column, the operator and the path.

Parameters

$outOutput
Test cases 1
Calls 1

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 2