1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-30795: JSON_SCHEMA_VALID bugs mentioned in comment

comment 2)
Analysis:
flag to check unique gets reset every time. Hence unique values cannot be
correctly checked
Fix:
do not reset the flag that checks unique for null, true and false
values.

comment 3)
Analysis:
current implementation checks for appropriate value but does not
return true.
Fix:
return true on error

comment 4)
Analysis:
Current implementation did not check for value type for values
inside required array.
Fix:
Check values inside required array
This commit is contained in:
Rucha Deodhar
2023-03-06 18:00:04 +05:30
parent 358b8495f5
commit 8939e21dc5
3 changed files with 102 additions and 2 deletions

View File

@ -3357,4 +3357,46 @@ SET @schema_reference= '{"$defs": "http://example.com/custom-email-validator.jso
SELECT JSON_SCHEMA_VALID(@schema_reference, '{}');
--echo #
--echo # MDEV-30795: JSON_SCHEMA_VALID bugs mentioned in comment
--echo #
SET @schema= '{
"type":"array",
"uniqueItems":true
}';
SELECT JSON_SCHEMA_VALID(@schema, '[null, null]');
SET @schema_max_items= '{"maxItems":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_max_items, '[]');
SET @schema_min_items= '{"minItems":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_min_items, '[]');
SET @schema_max_properties= '{"maxProperties":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_max_properties, '{}');
SET @schema_min_properties= '{"minProperties":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_min_properties, '{}');
SET @schema_multiple_of= '{"multipleOf":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_multiple_of, '2');
SET @schema_max_contains= '{"maxContains":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_max_contains, '[]');
SET @schema_min_contains= '{"minContains":-1}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema_min_contains, '[]');
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 # End of 11.1 test