final class JsonRule
Restricted visibility: declared "@visibility SqlSemantics\Platform\PostgreSql\Lowering". Code outside that scope must not name this declaration.

Lowers the SQL/JSON constructors and aggregates and the clauses they share with the query functions.

Rule: PG-JSON-LOWERING-001. Scope: the JSON_OBJECT, JSON_ARRAY, JSON, JSON_SCALAR and JSON_SERIALIZE productions of func_expr_common_subexpr, json_aggregate_func, json_value_expr, json_value_expr_list, json_format_clause, json_format_clause_opt, json_encoding_clause_opt (16), json_returning_clause_opt (17), json_output_clause_opt (16), json_name_and_value_list, json_name_and_value, json_object_constructor_null_clause_opt, json_array_constructor_null_clause_opt, json_array_aggregate_order_by_clause_opt, json_key_uniqueness_constraint_opt. Constructors: the classes of Statement/Invocation/Json and Json/Constructor, and KeywordCall for the legacy JSON_OBJECT with plain arguments. KEYS after WITH or WITHOUT UNIQUE is noise (see InvocationNoise). An encoding other than UTF8, UTF16 or UTF32 is rejected by the grammar's action with an AnalysisException. Termination: lists are flattened iteratively. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-JSON-CREATION-TABLE, https://www.postgresql.org/docs/17/functions-aggregate.html. Status: Implemented.

Methods§

public function __construct(private Lowering $lowering)

Parameters

$loweringLoweringThe hub
public function order(Node $clause): list<SortItem>

Lowers json_array_aggregate_order_by_clause_opt.

Parameters

$clauseNode

Returns

list<SortItem>

Throws

ImplementationGap When the production has no rule
Test cases 1
Called from 1
Calls 1
public function pairs(Node $list): list<JsonPair>
public function encodingClause(Node $clause): ?Name

Lowers json_encoding_clause_opt of PostgreSQL 16; no clause is null.

Parameters

$clauseNode

Returns

Throws

AnalysisException When the encoding is not UTF8, UTF16 or UTF32
ImplementationGap When the production has no rule
Test cases 1
Called from 1
Calls 2
public function encoding(Node $name): Name

Lowers the encoding name of a FORMAT clause.

Parameters

$nameNode

Returns

Throws

AnalysisException When the encoding is not UTF8, UTF16 or UTF32, which the action of `json_format_clause` in `gram.y` rejects (`makeJsonEncoding` called by `json_encoding_clause_opt` in PostgreSQL 16)
Called from 2
Calls 2
public function returning(Node $returning): ?JsonReturning

Lowers json_returning_clause_opt or json_output_clause_opt; no clause is null.

Parameters

$returningNode

Throws

ImplementationGap When the production has no rule
Test cases 1
Called from 9
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private const NULLS = ['json_object_constructor_null_clause_opt:' => null, 'json_object_constructor_n…
private const UNIQUENESS = ['json_key_uniqueness_constraint_opt:' => null, 'json_key_uniqueness_constraint…
private Lowering $lowering

Test cases 12§

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

Dedicated tests 12

Relations§

Instantiated in 9
Method calls 9