classJsonChecks
final class JsonChecks
Reports the SQL/JSON expressions the server rejects while analyzing them.
Rule: PG-JSON-CHECKS-001. An ENCODING is allowed only on a bytea value (a string constant or NULL is text there). JSON_QUERY accepts ERROR, NULL, EMPTY [ARRAY], EMPTY OBJECT and DEFAULT on empty and on error, and OMIT QUOTES only without a wrapper; JSON_EXISTS accepts ERROR, TRUE, FALSE and UNKNOWN on error; JSON_VALUE accepts ERROR, NULL and DEFAULT; FORMAT JSON in RETURNING is meaningful for JSON_QUERY only. The same behavior rules apply to the columns of JSON_TABLE, named in the message. Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-SQLJSON-QUERYING, transformJsonFuncExpr and transformJsonValueExpr in src/backend/parser/parse_expr.c of PostgreSQL 17. Termination: constant work. Status: Implemented.
Methods§
public function input(
Derivation $derivation,
JsonValueExpression $value,
ScalarFact $fact,
bool $parsed = false,
): voidReports an ENCODING written on a value that is not bytea.
Parameters
$derivation | Derivation | |
$value | JsonValueExpression | |
$fact | ScalarFact | |
$parsed | bool | Whether the value is parsed as a context item or by JSON(), which words the problem differently |
Test cases 1
Called from 1
Calls 5
- class-const Builtin::Bytea() line 59
- method-call Derivation::report() line 61
- new JsonProblem line 61
- class-const JsonProblemKind::ParsedEncodingWithoutBytea() line 61
- class-const JsonProblemKind::EncodingWithoutBytea() line 61
public function query(Derivation $derivation, JsonQueryFunction $function): voidReports the clause combinations and behaviors a query function does not accept.
Parameters
$derivation | Derivation | |
$function | JsonQueryFunction |
Test cases 1
Called from 1
Calls 7
- class-const JsonFunctionKind::Query() line 71
- method-call Derivation::report() line 72
- new JsonProblem line 72
- class-const JsonProblemKind::FormatInReturning() line 72
- function-call
strtolowerline 72 - class-const JsonProblemKind::QuotesWithWrapper() line 75
- method-call JsonChecks::behaviors() line 77
public function behaviors(
Derivation $derivation,
JsonFunctionKind $kind,
?JsonBehaviorClause $clause,
Name|null $column = null,
): voidReports the behaviors a function, or a JSON_TABLE column evaluated like it, does not accept.
Parameters
$derivation | Derivation | |
$kind | JsonFunctionKind | |
$clause | ?JsonBehaviorClause | |
$column | Name|null | The JSON_TABLE column the behaviors belong to |
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Invocation\JsonChecks::query() packages/sql-semantics-postgres/src/Rules/Invocation/JsonChecks.php:77
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes::typed() packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:180
Calls 5
- method-call JsonChecks::accepted() line 88
- method-call Derivation::report() line 89
- new JsonProblem line 90
- class-const JsonProblemKind::InvalidBehavior() line 90
- class-const JsonProblemKind::InvalidColumnBehavior() line 91
public function accepted(JsonFunctionKind $kind, JsonBehaviorKind $behavior): boolTells whether a function accepts a behavior.
Parameters
$kind | JsonFunctionKind | |
$behavior | JsonBehaviorKind |
Returns
boolTest cases 1
Called from 1
Calls 2
- function-call
in_arrayline 101 - class-const JsonChecks::ACCEPTED() line 101
Private surface 1§
Implementation details, listed for orientation only.
private const ACCEPTED = ['JSON_QUERY' => ['ERROR', 'NULL', 'EMPTY', 'EMPTY ARRAY', 'EMPTY OBJECT', 'DEF…Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes::typed() packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:180
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression::deriveValue() packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonValueExpression.php:48
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonQueryFunction.php:98
Method calls 3
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\TableFunctionShapes::typed() packages/sql-semantics-postgres/src/Rules/Resolution/TableFunctionShapes.php:180
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\JsonValueExpression::deriveValue() packages/sql-semantics-postgres/src/Statement/Invocation/Json/JsonValueExpression.php:48
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Json\Query\JsonQueryFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Json/Query/JsonQueryFunction.php:98