diff options
author | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-04 14:39:41 +0530 |
---|---|---|
committer | Rucha Deodhar <rucha.deodhar@mariadb.com> | 2023-04-26 11:00:08 +0530 |
commit | 1c25b5c02666420eba5708bb93a6a41e7d7a3a63 (patch) | |
tree | c4b3f7774ca8727b081f49924a8ad68fe430a567 /mysql-test | |
parent | ee41fa38fc3b393e0e7b73bed098274248b8492d (diff) | |
download | mariadb-git-1c25b5c02666420eba5708bb93a6a41e7d7a3a63.tar.gz |
MDEV-30977: Additional key values are not validating properly when using
unevaluatedProperties with properties declared in subschemas
Analysis:
When a key fails to validate for "properties" when "properties" is being
treated as alternate schema, it needs to fall back on alternate schema
for "properites" itself ("unevaluatedProperties" in context of the bug).
But that doesn't happen and we end up returning false (=validated)
Fix:
When "properties" fails to validate as an alternate schema, fall back on
alternate schema for "properties" itself.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/main/func_json.result | 22 | ||||
-rw-r--r-- | mysql-test/main/func_json.test | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 29939d69e83..da8cb3008bf 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -4497,6 +4497,28 @@ SET @schema_required='{"type":"object","required":[1,"str1", "str1"]}'; SELECT JSON_SCHEMA_VALID(@schema_required,'{"num1":1, "str1":"abc", "arr1":[1,2,3]}'); ERROR HY000: Invalid value for keyword required # +# MDEV-30977: Additional key values are not validating properly when using +# unevaluatedProperties with properties declared in subschemas +# +SET @unevaluatedProperties_schema= '{ + "allOf": [ + { + "type": "object", + "properties": { + "name": { "type": "string" } + } + } + ], + "properties": { + "type": { "enum": ["residential", "business"] } + }, + "required": ["type"], + "unevaluatedProperties": false +}'; +SELECT JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }'); +JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }') +0 +# # MDEV-30995: JSON_SCHEMA_VALID is not validating case sensitive when using regex # SET @schema_pattern='{ diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 5517dcfa6c8..4a400f1de90 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -3398,6 +3398,27 @@ SET @schema_required='{"type":"object","required":[1,"str1", "str1"]}'; --error ER_JSON_INVALID_VALUE_FOR_KEYWORD SELECT JSON_SCHEMA_VALID(@schema_required,'{"num1":1, "str1":"abc", "arr1":[1,2,3]}'); +--echo # +--echo # MDEV-30977: Additional key values are not validating properly when using +--echo # unevaluatedProperties with properties declared in subschemas +--echo # + +SET @unevaluatedProperties_schema= '{ + "allOf": [ + { + "type": "object", + "properties": { + "name": { "type": "string" } + } + } + ], + "properties": { + "type": { "enum": ["residential", "business"] } + }, + "required": ["type"], + "unevaluatedProperties": false +}'; +SELECT JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }'); --echo # --echo # MDEV-30995: JSON_SCHEMA_VALID is not validating case sensitive when using regex |