summaryrefslogtreecommitdiff
path: root/mysql-test/main/func_json.result
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/main/func_json.result')
-rw-r--r--mysql-test/main/func_json.result75
1 files changed, 73 insertions, 2 deletions
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index 6222d5f1feb..427be24d5ea 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -306,7 +306,7 @@ select json_merge('string', 123);
json_merge('string', 123)
NULL
Warnings:
-Warning 4038 Syntax error in JSON text in argument 1 to function 'json_merge' at position 1
+Warning 4038 Syntax error in JSON text in argument 1 to function 'json_merge_preserve' at position 1
select json_merge('"string"', 123);
json_merge('"string"', 123)
["string", 123]
@@ -326,7 +326,7 @@ select json_merge('a','b');
json_merge('a','b')
NULL
Warnings:
-Warning 4038 Syntax error in JSON text in argument 1 to function 'json_merge' at position 1
+Warning 4038 Syntax error in JSON text in argument 1 to function 'json_merge_preserve' at position 1
select json_merge('{"a":"b"}','{"c":"d"}');
json_merge('{"a":"b"}','{"c":"d"}')
{"a": "b", "c": "d"}
@@ -843,6 +843,77 @@ SELECT CHARSET(JSON_OBJECT());
CHARSET(JSON_OBJECT())
latin1
#
+# MDEV-13992 Implement JSON_MERGE_PATCH
+#
+CREATE TABLE merge_t(
+id INT PRIMARY KEY AUTO_INCREMENT,
+target VARCHAR(100), patch VARCHAR(100)
+);
+INSERT INTO merge_t(target, patch) VALUES
+('{"a":"b"}', '{"a":"c"}'),
+('{"a":"b"}', '{"b":"c"}'),
+('{"a":"b"}', '{"a":null}'),
+('{"a":"b", "b":"c"}', '{"a":null}'),
+('{"a":["b"]}', '{"a":"c"}'),
+('{"a":"c"}', '{"a":["b"]}'),
+('{"a": {"b":"c"}}', '{"a": {"b":"d", "c":null}}'),
+('{"a":[{"b":"c"}]}', '{"a": [1]}'),
+('["a","b"]', '["c","d"]'),
+('{"a":"b"}', '["c"]'),
+('{"a":"foo"}', 'null'),
+('{"a":"foo"}', '"bar"'),
+('{"e":null}', '{"a":1}'),
+('[1,2]', '{"a":"b", "c":null}'),
+('{}', '{"a":{"bb":{"ccc":null}}}'),
+(NULL, '{}'),
+('{}', NULL);
+SELECT id, target, patch,
+JSON_MERGE_PATCH(target, patch) AS merged,
+JSON_EXTRACT(JSON_MERGE_PATCH(target, patch), '$.a') AS a
+FROM merge_t ORDER BY id;
+id target patch merged a
+1 {"a":"b"} {"a":"c"} {"a": "c"} "c"
+2 {"a":"b"} {"b":"c"} {"a": "b", "b": "c"} "b"
+3 {"a":"b"} {"a":null} {} NULL
+4 {"a":"b", "b":"c"} {"a":null} {"b": "c"} NULL
+5 {"a":["b"]} {"a":"c"} {"a": "c"} "c"
+6 {"a":"c"} {"a":["b"]} {"a": ["b"]} ["b"]
+7 {"a": {"b":"c"}} {"a": {"b":"d", "c":null}} {"a": {"b": "d"}} {"b": "d"}
+8 {"a":[{"b":"c"}]} {"a": [1]} {"a": [1]} [1]
+9 ["a","b"] ["c","d"] ["c", "d"] NULL
+10 {"a":"b"} ["c"] ["c"] NULL
+11 {"a":"foo"} null null NULL
+12 {"a":"foo"} "bar" "bar" NULL
+13 {"e":null} {"a":1} {"e": null, "a": 1} 1
+14 [1,2] {"a":"b", "c":null} {"a": "b"} "b"
+15 {} {"a":{"bb":{"ccc":null}}} {"a": {"bb": {}}} {"bb": {}}
+16 NULL {} NULL NULL
+17 {} NULL NULL NULL
+DROP TABLE merge_t;
+SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '{"c":"d"}');
+JSON_MERGE_PATCH('{"a":"b"}', NULL, '{"c":"d"}')
+NULL
+SELECT JSON_MERGE_PATCH(NULL, '[1,2,3]');
+JSON_MERGE_PATCH(NULL, '[1,2,3]')
+[1, 2, 3]
+SELECT JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}');
+JSON_MERGE_PATCH('{"a":"b"}', NULL, '[1,2,3]', '{"c":null,"d":"e"}')
+{"d": "e"}
+SELECT JSON_MERGE_PATCH();
+ERROR 42000: Incorrect parameter count in the call to native function 'JSON_MERGE_PATCH'
+SELECT JSON_MERGE_PATCH('{}');
+ERROR 42000: Incorrect parameter count in the call to native function 'JSON_MERGE_PATCH'
+SELECT JSON_MERGE_PATCH('{', '[1,2,3]');
+JSON_MERGE_PATCH('{', '[1,2,3]')
+NULL
+Warnings:
+Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_merge_patch'
+SELECT JSON_MERGE_PATCH('{"a":"b"}', '[1,');
+JSON_MERGE_PATCH('{"a":"b"}', '[1,')
+NULL
+Warnings:
+Warning 4037 Unexpected end of JSON text in argument 2 to function 'json_merge_patch'
+#
# End of 10.2 tests
#
#