final class JsonBehavior
    implements Clause
    uses Snapshot
Public API: explicitly declared with @visibility public.

One behavior of an SQL/JSON function: a fixed result, an error, or DEFAULT expression.

Mirrors PostgreSQL's JsonBehavior node. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-SQLJSON-QUERYING.

Reading a default behaviordoctest
$behavior = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonBehavior(\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonBehaviorKind::Default, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral());
    $behavior->kind->value // => 'DEFAULT'
Rejecting an expression on a fixed behaviordoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonBehavior(\SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonBehaviorKind::Error, new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public Scalar|null $default = null

Methods§

public function __construct(public JsonBehaviorKind $kind, public Scalar|null $default = null)

Parameters

$kindJsonBehaviorKindThe behavior
$defaultScalar|nullThe expression of DEFAULT; given exactly for that kind
Calls 2
public function deriveClause(Derivation $derivation, Environment $environment): void

Derives the default expression.

Parameters

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

Writes the behavior.

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 3
Other tests reaching this symbol 5

Relations§

Instantiated in 2
Type checks 1
Type declarations 2