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

MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero

Analysis: multipleOf must be strictly greater then 0. However the
implementation only disallowed values strcitly less than 0
Fix: check if value is less than or equal to 0 instead of less than 0 and
return true.
Also fixed the incorrect return value for some other keywords.
This commit is contained in:
Rucha Deodhar
2023-03-02 17:19:36 +05:30
parent dffd1679ba
commit 2c4c7c8b02
4 changed files with 100 additions and 11 deletions

View File

@ -3494,4 +3494,43 @@ SET @schema = '{
SELECT JSON_SCHEMA_VALID(@schema, '2');
--echo #
--echo # MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero
--echo #
SET @schema = '{
"multipleOf": 0
}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "maxLength" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "minLength" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "maxProperties" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "minProperties" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "maxItems" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "minItems" : -3}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '2');
SET @schema= '{ "items" : ["str1"]}';
--error ER_JSON_INVALID_VALUE_FOR_KEYWORD
SELECT JSON_SCHEMA_VALID(@schema, '[]');
--echo # End of 11.1 test