classJsonValueExpression
final class JsonValueExpression
implements Clause
uses Snapshot
Public API: explicitly declared with
@visibility public.A value passed to an SQL/JSON function, with an optional FORMAT clause.
Mirrors PostgreSQL's JsonValueExpr. Whoever holds it derives it once, through deriveValue(), to read the value's facts. An ENCODING on a value that is not bytea is reported (PG-JSON-CHECKS-001). Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE.
(new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()))->format // => nullProperties§
public Scalar $valuepublic JsonFormat|null $format = nullMethods§
public function __construct(public Scalar $value, public JsonFormat|null $format = null)Parameters
$value | Scalar | The value |
$format | JsonFormat|null | The format written |
public function deriveValue(
Derivation $derivation,
Environment $environment,
bool $parsed = false,
): ScalarFactDerives the value and answers its facts.
Parameters
$derivation | Derivation | |
$environment | Environment | |
$parsed | bool | Whether the value is parsed as the context item or the operand of JSON(), which words the encoding problem differently |
Returns
Test cases 2
Called from 7
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayAggregate::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonArrayAggregate.php:80
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonParse::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonParse.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonSerialize::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonSerialize.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonPair::deriveClause() packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonPair.php:48
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression::deriveClause() packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonValueExpression.php:58
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonArgument::deriveClause() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonArgument.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonQueryFunction.php:91
Calls 3
- method-call Derivation::scalar() line 47
- method-call JsonChecks::input() line 48
- new JsonChecks line 48
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the value.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
Calls 1
- method-call JsonValueExpression::deriveValue() line 58
public function render(Output $out): voidWrites the value and the format.
Parameters
$out | Output |
Test cases 1
Calls 1
- method-call Output::node() line 66
Test cases 37§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 33
JsonChecksTest::testInputReportsAnEncodingOnANonByteaValuecallsJsonChecksTest::testQueryReportsFormatInReturningAndQuotesWithWrappercallsJsonArrayAggregateTest::testDeriveScalarDerivesTheOrderingcallsJsonArrayAggregateTest::testOutputNameIsJsonArrayaggcallsJsonArrayAggregateTest::testRenderWritesTheOrderingAndTheWindowcallsJsonArrayConstructorTest::testDeriveScalarIsJsoncallsJsonArrayConstructorTest::testRenderWritesTheNullClausecallsJsonObjectAggregateTest::testDeriveScalarDerivesTheFilterAndTheWindowcallsJsonObjectAggregateTest::testOutputNameIsJsonObjectaggcallsJsonObjectAggregateTest::testRejectsAValueThatWouldTakeTheUniquenesscallsJsonObjectAggregateTest::testRenderWritesTheClausesFilterAndWindowcallsJsonObjectConstructorTest::testDeriveScalarIsJsonOrTheReturningTypecallsJsonObjectConstructorTest::testRejectsALastValueThatWouldTakeTheUniquenesscallsJsonObjectConstructorTest::testRenderWritesTheClausescallsJsonParseTest::testDeriveScalarFollowsTheValuecallsJsonParseTest::testOutputNameIsJsoncallsJsonParseTest::testRejectsAValueThatWouldTakeTheUniquenesscallsJsonParseTest::testRenderWritesTheUniquenesscallsJsonSerializeTest::testDeriveScalarIsTextWithoutReturningcallsJsonSerializeTest::testOutputNameIsJsonSerializecallsJsonSerializeTest::testRenderWritesTheReturningClausecallsJsonPairTest::testDeriveClauseDerivesTheKeyAndTheValuecallsJsonPairTest::testRejectsAKeyBeforeValueThatIsNotPrimarycallsJsonPairTest::testRenderWritesBothSpellingscallsJsonArgumentTest::testDeriveClauseDerivesTheValuecallsJsonArgumentTest::testRenderWritesTheNamecallsJsonQueryFunctionTest::testDeriveScalarIsTheReturningTypecallsJsonQueryFunctionTest::testDeriveScalarReportsAnInvalidBehaviorcallsJsonQueryFunctionTest::testOutputNameIsTheFunctioncallsJsonQueryFunctionTest::testRejectsAPathThatWouldTakeTheWrappercallsJsonQueryFunctionTest::testRejectsAWrapperOutsideJsonQuerycallsJsonQueryFunctionTest::testRejectsReturningOnJsonExistscallsJsonQueryFunctionTest::testRenderWritesEveryClauseInOrdercalls
Relations§
Instantiated in 1
Method calls 6
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayAggregate::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonArrayAggregate.php:80
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonParse::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonParse.php:62
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonSerialize::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonSerialize.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonPair::deriveClause() packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonPair.php:48
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonArgument::deriveClause() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonArgument.php:44
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonQueryFunction.php:91
Constant reads 1
Type checks 1
Type declarations 9
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\Invocations packages/sql-semantics-postgres/src/Lowering/Invocation/Invocations.php:141
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonRule packages/sql-semantics-postgres/src/Lowering/Invocation/JsonRule.php:183
- type SqlSemantics\Platform\PostgreSql\Rules\Invocation\JsonChecks packages/sql-semantics-postgres/src/Rules/Invocation/JsonChecks.php:54
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayAggregate packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonArrayAggregate.php:57
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonParse packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonParse.php:44
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonSerialize packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonSerialize.php:42
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonPair packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonPair.php:37
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonArgument packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonArgument.php:35
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonQueryFunction.php:64