classJsonExtraction
final class JsonExtraction
implements Scalar
uses Snapshot
@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.
$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 $columnpublic Text $pathpublic bool $unquote = falseMethods§
public function __construct(
public ColumnUse $column,
public Text $path,
public bool $unquote = false,
)Parameters
Calls 1
- static-call Check::input() line 50
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the column; the result is JSON or text.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 10
- method-call Operands::single() line 58
- new Operands line 58
- method-call Derivation::scalar() line 58
- new ScalarFact line 60
- new Known line 60
- new Character line 60
- class-const CharacterKind::LongText() line 60
- new Elementary line 60
- class-const ElementaryKind::Json() line 60
- class-const Nullability::Nullable() line 60
public function render(Output $out): voidWrites the column, the operator and the path.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::node() line 68
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.