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

JSON_EXISTS, JSON_QUERY or JSON_VALUE (PostgreSQL 17): a JSON path applied to a value.

Mirrors PostgreSQL's JsonFuncExpr. JSON_EXISTS takes no RETURNING, wrapper, quotes or ON EMPTY; JSON_VALUE takes no wrapper or quotes. Rule: PG-JSON-QUERY-001. Facts: the RETURNING type, otherwise boolean, jsonb or text; the result may be NULL. Diagnostics: the behaviors and clause combinations the server rejects (PG-JSON-CHECKS-001). The result column is named after the function in lower case. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-SQLJSON-QUERYING. Status: Implemented.

Reading a JSON_EXISTS calldoctest
$exists = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction(
        \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonFunctionKind::Exists,
        new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()),
        new \SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\StringConstant('$.a')),
    );
    $exists->outputName()->value // => 'json_exists'

Properties§

public list<JsonArgument> $passing
public Scalar $path
public JsonReturning|null $returning = null
public JsonWrapping|null $wrapper = null
public JsonQuoting|null $quotes = null
public JsonBehaviorClause|null $behavior = null

Methods§

public function __construct(
    public JsonFunctionKind $kind,
    public JsonValueExpression $context,
    public Scalar $path,
    list<JsonArgument> $passing = [],
    public JsonReturning|null $returning = null,
    public JsonWrapping|null $wrapper = null,
    public JsonQuoting|null $quotes = null,
    public JsonBehaviorClause|null $behavior = null,
)

Parameters

$kindJsonFunctionKindThe function
$contextJsonValueExpressionThe JSON value the path applies to
$pathScalarThe JSON path
$passinglist<JsonArgument>The path variables passed
$returningJsonReturning|nullThe RETURNING clause
$wrapperJsonWrapping|nullThe wrapper clause of JSON_QUERY
$quotesJsonQuoting|nullThe quotes clause of JSON_QUERY
$behaviorJsonBehaviorClause|nullThe ON EMPTY and ON ERROR behaviors
Calls 7
public function outputName(): Name

Names an unaliased result column after the function.

Returns

Test cases 1
Calls 2
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands and clauses, reports rejected combinations, and derives the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes the function with its clauses in the order of the grammar.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 8§

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

Dedicated tests 7
Other tests reaching this symbol 1

Relations§

Instantiated in 3
Type declarations 2