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

JSON_ARRAY (values [NULL | ABSENT ON NULL] [RETURNING type]).

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

Reading an array constructordoctest
$array = new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Constructor\JsonArrayConstructor([new \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression(new \SqlSemantics\Platform\PostgreSql\Statement\Literal\NullLiteral())], \SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonNullHandling::Keep);
    [count($array->values), $array->nulls->value] // => [1, 'NULL']

Properties§

public list<JsonValueExpression> $values
public JsonNullHandling|null $nulls = null
public JsonReturning|null $returning = null

Methods§

public function __construct(
    list<JsonValueExpression> $values,
    public JsonNullHandling|null $nulls = null,
    public JsonReturning|null $returning = null,
)

Parameters

$valueslist<JsonValueExpression>The elements
$nullsJsonNullHandling|nullThe NULL clause written
$returningJsonReturning|nullThe RETURNING clause
Calls 3
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 elements and the returning type.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

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

Writes JSON_ARRAY with its elements and clauses.

Parameters

$outOutput
Test cases 1
Calls 2

Test cases 4§

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

Dedicated tests 4

Relations§

Instantiated in 2