classJsonTest
final class JsonTest
implements Scalar
uses Snapshot
Public API: explicitly declared with
@visibility public.A test of whether a value is JSON of a kind: a IS [NOT] JSON [VALUE|ARRAY|OBJECT|SCALAR] [WITH|WITHOUT UNIQUE KEYS].
Mirrors PostgreSQL's JsonIsPredicate node.
Rule: PG-JSON-TEST-001. Facts: boolean for an operand of type text, json, jsonb or bytea (a string constant is read as text), NULL when the operand can be; any other operand type is reported. The operand must keep its place before IS (PG-PRECEDENCE-001). Source: https://www.postgresql.org/docs/17/functions-json.html#FUNCTIONS-SQLJSON-MISC. Status: Implemented.
(new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze("SELECT '{}' IS NOT JSON OBJECT")->toString() // => "SELECT '{}' IS NOT JSON OBJECT"Properties§
public Scalar $operandpublic bool $negatedpublic JsonItemKind $kindpublic JsonUniqueKeys|null $uniqueness = nullMethods§
public function __construct(
public Scalar $operand,
public bool $negated,
public JsonItemKind $kind,
public JsonUniqueKeys|null $uniqueness = null,
)Parameters
$operand | Scalar | The tested value |
$negated | bool | Whether NOT is written |
$kind | JsonItemKind | The kind of JSON item tested for |
$uniqueness | JsonUniqueKeys|null | The key uniqueness clause, or null when none is written |
Calls 4
- static-call Check::input() line 50
- method-call Precedence::before() line 50
- new Precedence line 50
- class-const Precedence::IS() line 50
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operand and checks that it can hold JSON text.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 11
- method-call Derivation::scalar() line 58
- new OperandChecks line 59
- new ScalarFact line 61
- method-call OperandChecks::accepted() line 61
- class-const Builtin::Text() line 61
- class-const Builtin::Varchar() line 61
- class-const Builtin::Bpchar() line 61
- class-const Builtin::Json() line 61
- class-const Builtin::Jsonb() line 61
- class-const Builtin::Bytea() line 61
- method-call OperandChecks::nullability() line 61
public function render(Output $out): voidWrites the value and the test.
Parameters
$out | Output |
Test cases 1
Calls 3
- method-call Output::node() line 69
- method-call Output::keyword() line 71
- function-call
explodeline 73
Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
Other tests reaching this symbol 5
PrecedenceTest::testTakesUniquenessFindsAnOpenJsonTestOnTheRightEdgecallsJsonObjectAggregateTest::testRejectsAValueThatWouldTakeTheUniquenesscallsJsonObjectConstructorTest::testRejectsALastValueThatWouldTakeTheUniquenesscallsJsonParseTest::testRejectsAValueThatWouldTakeTheUniquenesscallsJsonQueryFunctionTest::testRejectsAPathThatWouldTakeTheWrappercalls
Relations§
Instantiated in 1
Type checks 2
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Precedence::predicates() packages/sql-semantics-postgres/src/Rules/Expression/Precedence.php:248
- instanceof SqlSemantics\Platform\PostgreSql\Rules\Expression\Precedence::takesUniqueness() packages/sql-semantics-postgres/src/Rules/Expression/Precedence.php:365