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

JSON_OBJECT (key : value, ... [NULL | ABSENT ON NULL] [WITH | WITHOUT UNIQUE] [RETURNING type]).

Mirrors PostgreSQL's JsonObjectConstructor. Without pairs, no NULL or uniqueness clause can be written. Rule: PG-JSON-OBJECT-001. Facts: the RETURNING type, otherwise json; never NULL. The result column is named json_object. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE. Status: Implemented.

Reading an empty object constructordoctest
$object = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonObjectConstructor([]);
    [$object->pairs, $object->outputName()->value] // => [[], 'json_object']
Rejecting a NULL clause without pairsdoctest
new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonObjectConstructor([], \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonNullHandling::Absent) // throws \SqlSemantics\Platform\PostgreSql\Model\Diagnostic\InvalidConstruction

Properties§

public list<JsonPair> $pairs
public JsonNullHandling|null $nulls = null
public JsonUniqueKeys|null $unique = null
public JsonReturning|null $returning = null

Methods§

public function __construct(
    list<JsonPair> $pairs,
    public JsonNullHandling|null $nulls = null,
    public JsonUniqueKeys|null $unique = null,
    public JsonReturning|null $returning = null,
)

Parameters

$pairslist<JsonPair>The key and value pairs
$nullsJsonNullHandling|nullThe NULL clause written
$uniqueJsonUniqueKeys|nullThe uniqueness clause written
$returningJsonReturning|nullThe RETURNING clause
Calls 6
public function outputName(): Name

Names an unaliased result column.

Returns

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

Derives the pairs and the returning type.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes JSON_OBJECT with its pairs and clauses.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 5§

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

Dedicated tests 5

Relations§

Instantiated in 2