1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +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

@@ -4605,4 +4605,33 @@ SET @schema = '{
}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword enum
#
# MDEV-30704: JSON_SCHEMA_VALID: multipleOf must be greater than zero
#
SET @schema = '{
"multipleOf": 0
}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword multipleOf
SET @schema= '{ "maxLength" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword maxLength
SET @schema= '{ "minLength" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword minLength
SET @schema= '{ "maxProperties" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword maxProperties
SET @schema= '{ "minProperties" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword minProperties
SET @schema= '{ "maxItems" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword maxItems
SET @schema= '{ "minItems" : -3}';
SELECT JSON_SCHEMA_VALID(@schema, '2');
ERROR HY000: Invalid value for keyword maxLength
SET @schema= '{ "items" : ["str1"]}';
SELECT JSON_SCHEMA_VALID(@schema, '[]');
ERROR HY000: Invalid value for keyword items
# End of 11.1 test