classJsonBehavior
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.
$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'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\InvalidConstructionProperties§
public JsonBehaviorKind $kindpublic Scalar|null $default = nullMethods§
public function __construct(public JsonBehaviorKind $kind, public Scalar|null $default = null)Parameters
$kind | JsonBehaviorKind | The behavior |
$default | Scalar|null | The expression of DEFAULT; given exactly for that kind |
Calls 2
- static-call Check::input() line 38
- class-const JsonBehaviorKind::Default() line 38
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the default expression.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
Calls 1
- method-call Derivation::scalar() line 47
public function render(Output $out): voidWrites the behavior.
Parameters
$out | Output |
Test cases 1
Calls 2
- method-call Output::keyword() line 56
- function-call
explodeline 56
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
JsonChecksTest::testBehaviorsNamesTheColumncallsJsonBehaviorClauseTest::testDeriveClauseDerivesBothDefaultscallsJsonBehaviorClauseTest::testRenderWritesOnEmptyThenOnErrorcallsJsonQueryFunctionTest::testDeriveScalarReportsAnInvalidBehaviorcallsJsonQueryFunctionTest::testRenderWritesEveryClauseInOrdercalls
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonQueryRule::behavior() packages/sql-semantics-postgres/src/Lowering/Invocation/JsonQueryRule.php:188
- new SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonQueryRule::behavior() packages/sql-semantics-postgres/src/Lowering/Invocation/JsonQueryRule.php:195
Type checks 1
Type declarations 2
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonQueryRule packages/sql-semantics-postgres/src/Lowering/Invocation/JsonQueryRule.php:184
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonBehaviorClause packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonBehaviorClause.php:34