1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MDEV-30703: JSON_SCHEMA_VALID : Enum array must have at least one value

Analysis: Current implementation does not check the number of elements in
the enum array and whether they are unique or not.
Fix: Add a counter that counts number of elements and before inserting the
element in the enum hash check whether it exists.
This commit is contained in:
Rucha Deodhar
2023-03-02 19:09:45 +05:30
parent d555f38af8
commit dffd1679ba
4 changed files with 67 additions and 20 deletions

View File

@ -3357,6 +3357,7 @@ 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 #
@ -3474,4 +3475,23 @@ SET @invalid_schema= '{"type":"object"
}';
SELECT JSON_SCHEMA_VALID(@invalid_schema, '{"number1":3, "obj2":{"key1":3}}');
--echo #
--echo # MDEV-30703: JSON_SCHEMA_VALID : Enum array must have at least one value
--echo #
SET @schema = '{
"type":"array",
"enum": []
}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema = '{
"type":"number",
"enum": [2, 2]
}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
--echo # End of 11.1 test