final class PathColumn
    implements JsonTableColumn
    uses Snapshot
Public API: explicitly declared with @visibility public.

A name type PATH path or name type EXISTS PATH path column of JSON_TABLE, with its ON EMPTY and ON ERROR responses.

Rule: MYSQL-JSON-TABLE-COLUMN-001 (path). The column has the declared type and is NULL when the path finds nothing and by default on an error; an EXISTS column is 1 or 0. The server accepts ON ERROR before ON EMPTY and warns that the order is deprecated, so the written order is kept. Terminates: the parts are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/json-table-functions.html. Status: Implemented.

Reading a path columndoctest
$column = new \SqlSemantics\Platform\MySql\Statement\Call\Json\PathColumn(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('a'), new \SqlSemantics\Platform\MySql\Statement\Type\Integral(\SqlSemantics\Platform\MySql\Statement\Type\Kind\IntegralKind::Int), new \SqlSemantics\Platform\MySql\Statement\Literal\StringLiteral(['$.a']));
    [$column->name->value, $column->type->name(), $column->exists] // => ['a', 'INT', false]
Refusing the reversed order without both responsesdoctest
new \SqlSemantics\Platform\MySql\Statement\Call\Json\PathColumn(new \SqlSemantics\Platform\MySql\Model\Statement\Identifier\Name('a'), new \SqlSemantics\Platform\MySql\Statement\Type\Integral(\SqlSemantics\Platform\MySql\Statement\Type\Kind\IntegralKind::Int), new \SqlSemantics\Platform\MySql\Statement\Literal\StringLiteral(['$.a']), errorFirst: true) // throws \SqlSemantics\Platform\MySql\Model\Diagnostic\InvalidConstruction

Properties§

public Name $name
public TypeName $type
public bool $exists = false
public CollationName|null $collation = null
public JsonResponse|null $onEmpty = null
public JsonResponse|null $onError = null
public bool $errorFirst = false

Methods§

public function __construct(
    public Name $name,
    public TypeName $type,
    public StringLiteral $path,
    public bool $exists = false,
    public CollationName|null $collation = null,
    public JsonResponse|null $onEmpty = null,
    public JsonResponse|null $onError = null,
    public bool $errorFirst = false,
)

Parameters

$nameNameThe column name
$typeTypeNameThe declared type
$pathStringLiteralThe path
$existsboolWhether the column is an EXISTS column
$collationCollationName|nullThe written collation
$onEmptyJsonResponse|nullThe ON EMPTY response
$onErrorJsonResponse|nullThe ON ERROR response
$errorFirstboolWhether ON ERROR is written before ON EMPTY
Calls 1
public function deriveColumns(
    Derivation $derivation,
    Environment $environment,
): list<OutputSlot>

Derives the path and the defaults and answers the column.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Test cases 1
Calls 5
public function render(Output $out): void

Writes the column.

Parameters

$outOutput
Test cases 1
Calls 5

Test cases 4§

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

Dedicated tests 2
Other tests reaching this symbol 2

Relations§

Instantiated in 2
Type declarations 1