summaryrefslogtreecommitdiff
path: root/mysql-test/main/func_json.test
diff options
context:
space:
mode:
authorRucha Deodhar <rucha.deodhar@mariadb.com>2022-07-30 16:56:18 +0530
committerRucha Deodhar <rucha.deodhar@mariadb.com>2022-08-11 13:47:25 +0530
commit11d6de7032ab7fb221315ee5680504f34d1ba3ed (patch)
treeafd7888c3d6b33998631a43b9e40cc7712f780fb /mysql-test/main/func_json.test
parentbfdc4ff22ecf626eb46479e1a0dc1049d61a8d78 (diff)
downloadmariadb-git-11d6de7032ab7fb221315ee5680504f34d1ba3ed.tar.gz
MDEV-29212: json_overlaps() does not check nested key-value pair correctly
Analysis: JSON_OVERLAPS() does not check nested key-value pair completely. If there is nested object, then it only scans and validates if two json values overlap until one of the value (which is of type object) is exhausted. This does not really check if the two values of keys are exacly the same, instead it only checks if key-value pair of one is present in key-value pair of the other Fix: Normalize the values (which are of type object) and compare using string compare. This will validate if two values are exactly the same.
Diffstat (limited to 'mysql-test/main/func_json.test')
-rw-r--r--mysql-test/main/func_json.test9
1 files changed, 9 insertions, 0 deletions
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index 91d5002acc8..3c0c72b6758 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -1534,5 +1534,14 @@ SELECT JSON_EXISTS(@json, '$[2][2][1 to 4]');
SELECT * FROM JSON_TABLE('{"foo":["bar","qux"]}','$**.*[0]' COLUMNS(col1 CHAR(8) PATH '$[0]')) AS jt;
--echo #
+--echo # MDEV-29212: json_overlaps() does not check nested key-value pair correctly
+--echo #
+
+SET @json1 = '{"kk":{"k1":"v1","k2":"v2"}}';
+SET @json2 = '{"kk":{"k1":"v1","k2":"v2","k3":"v3"}}';
+SELECT JSON_OVERLAPS(@json2, @json1);
+SELECT JSON_OVERLAPS(@json1, @json2);
+
+--echo #
--echo # End of 10.9 Test
--echo #