classJsonPair
final class JsonPair
implements Clause
uses Snapshot
Public API: explicitly declared with
@visibility public.A key and its value in JSON_OBJECT or JSON_OBJECTAGG.
Mirrors PostgreSQL's JsonPair node. With the VALUE spelling the key is a primary expression; a key that would need parentheses is rejected. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE.
$pair = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonPair(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral(), new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral()));
$pair->spelling->value // => ':'Properties§
public Scalar $keypublic JsonValueExpression $valuepublic KeyValueSpelling $spelling = KeyValueSpelling::ColonMethods§
public function __construct(
public Scalar $key,
public JsonValueExpression $value,
public KeyValueSpelling $spelling = KeyValueSpelling::Colon,
)Parameters
$key | Scalar | The key |
$value | JsonValueExpression | The value |
$spelling | KeyValueSpelling | How the key joins the value |
Calls 4
- class-const KeyValueSpelling::Colon() line 37
- static-call Check::input() line 39
- method-call Precedence::primary() line 39
- new Precedence line 39
public function deriveClause(Derivation $derivation, Environment $environment): voidDerives the key and the value.
Parameters
$derivation | Derivation | |
$environment | Environment |
Test cases 1
Called from 1
Calls 2
- method-call Derivation::scalar() line 47
- method-call JsonValueExpression::deriveValue() line 48
public function render(Output $out): voidWrites the key, the joining word or symbol, and the value.
Parameters
$out | Output |
Test cases 1
Calls 4
- method-call Output::node() line 56
- class-const KeyValueSpelling::Value() line 57
- method-call Output::keyword() line 58
- method-call Output::symbol() line 60
Test cases 10§
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 7
JsonObjectAggregateTest::testDeriveScalarDerivesTheFilterAndTheWindowcallsJsonObjectAggregateTest::testOutputNameIsJsonObjectaggcallsJsonObjectAggregateTest::testRejectsAValueThatWouldTakeTheUniquenesscallsJsonObjectAggregateTest::testRenderWritesTheClausesFilterAndWindowcallsJsonObjectConstructorTest::testDeriveScalarIsJsonOrTheReturningTypecallsJsonObjectConstructorTest::testRejectsALastValueThatWouldTakeTheUniquenesscallsJsonObjectConstructorTest::testRenderWritesTheClausescalls
Relations§
Instantiated in 1
Method calls 1
Constant reads 1
Type declarations 3
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\Invocations packages/sql-semantics-postgres/src/Lowering/Invocation/Invocations.php:184
- type SqlSemantics\Platform\PostgreSql\Lowering\Invocation\JsonRule packages/sql-semantics-postgres/src/Lowering/Invocation/JsonRule.php:228
- type SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonObjectAggregate packages/sql-semantics-postgres/src/Statement/Invocation/Json/Constructor/JsonObjectAggregate.php:54