mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 07:39:58 +00:00
## Problem `pg_jsonschema` and `pg_session_jwt` are not yet covered by tests ## Summary of changes Added the tests for these extensions.
49 lines
1.0 KiB
SQL
49 lines
1.0 KiB
SQL
-- Define schema
|
|
SELECT jsonschema_is_valid('{
|
|
"type": "object",
|
|
"properties": {
|
|
"username": { "type": "string" },
|
|
"age": { "type": "integer" }
|
|
},
|
|
"required": ["username"]
|
|
}'::json);
|
|
|
|
-- Valid instance
|
|
SELECT jsonschema_validation_errors(
|
|
'{
|
|
"type": "object",
|
|
"properties": {
|
|
"username": { "type": "string" },
|
|
"age": { "type": "integer" }
|
|
},
|
|
"required": ["username"]
|
|
}'::json,
|
|
'{"username": "alice", "age": 25}'::json
|
|
);
|
|
|
|
-- Invalid instance: missing required "username"
|
|
SELECT jsonschema_validation_errors(
|
|
'{
|
|
"type": "object",
|
|
"properties": {
|
|
"username": { "type": "string" },
|
|
"age": { "type": "integer" }
|
|
},
|
|
"required": ["username"]
|
|
}'::json,
|
|
'{"age": 25}'::json
|
|
);
|
|
|
|
-- Invalid instance: wrong type for "age"
|
|
SELECT jsonschema_validation_errors(
|
|
'{
|
|
"type": "object",
|
|
"properties": {
|
|
"username": { "type": "string" },
|
|
"age": { "type": "integer" }
|
|
},
|
|
"required": ["username"]
|
|
}'::json,
|
|
'{"username": "bob", "age": "twenty"}'::json
|
|
);
|