mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
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.
This commit is contained in:
@ -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]}');
|
SELECT JSON_SCHEMA_VALID(@schema_required,'{"num1":1, "str1":"abc", "arr1":[1,2,3]}');
|
||||||
ERROR HY000: Invalid value for keyword required
|
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
|
# MDEV-30995: JSON_SCHEMA_VALID is not validating case sensitive when using regex
|
||||||
#
|
#
|
||||||
SET @schema_pattern='{
|
SET @schema_pattern='{
|
||||||
|
@ -3398,6 +3398,27 @@ SET @schema_required='{"type":"object","required":[1,"str1", "str1"]}';
|
|||||||
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
|
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
|
||||||
SELECT JSON_SCHEMA_VALID(@schema_required,'{"num1":1, "str1":"abc", "arr1":[1,2,3]}');
|
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 #
|
||||||
--echo # MDEV-30995: JSON_SCHEMA_VALID is not validating case sensitive when using regex
|
--echo # MDEV-30995: JSON_SCHEMA_VALID is not validating case sensitive when using regex
|
||||||
|
@ -1883,6 +1883,13 @@ bool Json_schema_properties::validate_as_alternate(const json_engine_t *je,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (alternate_schema && alternate_schema->validate_as_alternate(je, k_start, k_end))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1892,6 +1899,8 @@ Json_schema_additional_and_unevaluated::
|
|||||||
const uchar* k_start,
|
const uchar* k_start,
|
||||||
const uchar* k_end)
|
const uchar* k_end)
|
||||||
{
|
{
|
||||||
|
if (!allowed)
|
||||||
|
return true;
|
||||||
return validate_schema_items(je, &schema_list);
|
return validate_schema_items(je, &schema_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user