mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-11557 port MySQL-5.7 JSON tests to MariaDB.
Fixes for issues found.
This commit is contained in:
@ -57,7 +57,7 @@ json_array_append('["a", "b"]', '$', FALSE)
|
||||
["a", "b", false]
|
||||
select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2);
|
||||
json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2)
|
||||
{"k1":1, "k2":["a", "b", 2]}
|
||||
{"k1": 1, "k2": ["a", "b", 2]}
|
||||
select json_array_append('["a", ["b", "c"], "d"]', '$[0]', 2);
|
||||
json_array_append('["a", ["b", "c"], "d"]', '$[0]', 2)
|
||||
[["a", 2], ["b", "c"], "d"]
|
||||
@ -190,10 +190,10 @@ json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY")
|
||||
NULL
|
||||
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1", "$.key2");
|
||||
json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1", "$.key2")
|
||||
["asd", [2,3]]
|
||||
["asd", [2, 3]]
|
||||
select json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2");
|
||||
json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2")
|
||||
[5, [2,3]]
|
||||
[5, [2, 3]]
|
||||
select json_extract('{"key0":true, "key1":"qwe"}', "$.key1");
|
||||
json_extract('{"key0":true, "key1":"qwe"}', "$.key1")
|
||||
"qwe"
|
||||
@ -205,7 +205,7 @@ json_extract('[10, 20, [30, 40]]', '$[2][*]')
|
||||
[30, 40]
|
||||
select json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]');
|
||||
json_extract('[10, 20, [{"a":3}, 30, 40]]', '$[2][*]')
|
||||
[{"a":3}, 30, 40]
|
||||
[{"a": 3}, 30, 40]
|
||||
select json_extract('1', '$');
|
||||
json_extract('1', '$')
|
||||
1
|
||||
@ -220,29 +220,29 @@ json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a')
|
||||
[[3, 4]]
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
||||
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word')
|
||||
{"a":1, "b":{"c":1, "k1":"word"}, "d":[1, 2]}
|
||||
{"a": 1, "b": {"c": 1, "k1": "word"}, "d": [1, 2]}
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3);
|
||||
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3)
|
||||
{"a":1, "b":{"c":1}, "d":[1, 2, 3]}
|
||||
{"a": 1, "b": {"c": 1}, "d": [1, 2, 3]}
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2);
|
||||
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2)
|
||||
{"a":[1, 2], "b":{"c":1}, "d":[1, 2]}
|
||||
{"a": [1, 2], "b": {"c": 1}, "d": [1, 2]}
|
||||
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word');
|
||||
json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word')
|
||||
{"a":1, "b":{"c":1}, "d":[1, 2]}
|
||||
{"a": 1, "b": {"c": 1}, "d": [1, 2]}
|
||||
select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
||||
json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]')
|
||||
{ "a": 10, "b": [2, 3], "c":"[true, false]"}
|
||||
{"a": 10, "b": [2, 3], "c": "[true, false]"}
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
||||
json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]')
|
||||
{ "a": 10, "b": [2, 3]}
|
||||
{"a": 10, "b": [2, 3]}
|
||||
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]');
|
||||
json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]')
|
||||
{ "a": 10, "b": "[true, false]"}
|
||||
{"a": 10, "b": "[true, false]"}
|
||||
set @j = '["a", ["b", "c"], "d"]';
|
||||
select json_remove(@j, '$[0]');
|
||||
json_remove(@j, '$[0]')
|
||||
[ ["b", "c"], "d"]
|
||||
[["b", "c"], "d"]
|
||||
select json_remove(@j, '$[1]');
|
||||
json_remove(@j, '$[1]')
|
||||
["a", "d"]
|
||||
@ -323,7 +323,7 @@ Warnings:
|
||||
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_merge' at position 1
|
||||
select json_merge('{"a":"b"}','{"c":"d"}');
|
||||
json_merge('{"a":"b"}','{"c":"d"}')
|
||||
{"a":"b", "c":"d"}
|
||||
{"a": "b", "c": "d"}
|
||||
SELECT JSON_MERGE('[1, 2]', '{"id": 47}');
|
||||
JSON_MERGE('[1, 2]', '{"id": 47}')
|
||||
[1, 2, {"id": 47}]
|
||||
@ -485,15 +485,13 @@ json_set('{"a":12}', '$[0]', 100)
|
||||
100
|
||||
select json_set('{"a":12}', '$[0].a', 100);
|
||||
json_set('{"a":12}', '$[0].a', 100)
|
||||
{"a":100}
|
||||
{"a": 100}
|
||||
select json_set('{"a":12}', '$[0][0].a', 100);
|
||||
json_set('{"a":12}', '$[0][0].a', 100)
|
||||
{"a":100}
|
||||
{"a": 100}
|
||||
select json_set('{"a":12}', '$[0][1].a', 100);
|
||||
json_set('{"a":12}', '$[0][1].a', 100)
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_set'
|
||||
{"a": 12}
|
||||
select json_value('{"\\"key1":123}', '$."\\"key1"');
|
||||
json_value('{"\\"key1":123}', '$."\\"key1"')
|
||||
123
|
||||
@ -503,3 +501,54 @@ json_value('{"\\"key1\\"":123}', '$."\\"key1\\""')
|
||||
select json_value('{"key 1":123}', '$."key 1"');
|
||||
json_value('{"key 1":123}', '$."key 1"')
|
||||
123
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[2]");
|
||||
json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[2]")
|
||||
1
|
||||
select json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[3]");
|
||||
json_contains_path('{"a":[{"c":[1,{"a":[0,1,2]},3]}], "b":[1,2,3]}', 'one', "$**.a[3]")
|
||||
0
|
||||
select json_extract( '[1]', '$[0][0]' );
|
||||
json_extract( '[1]', '$[0][0]' )
|
||||
1
|
||||
select json_extract( '[1]', '$[1][0]' );
|
||||
json_extract( '[1]', '$[1][0]' )
|
||||
NULL
|
||||
select json_extract( '[1]', '$**[0]' );
|
||||
json_extract( '[1]', '$**[0]' )
|
||||
[1]
|
||||
select json_extract( '[1]', '$**[0][0]' );
|
||||
json_extract( '[1]', '$**[0][0]' )
|
||||
[1]
|
||||
select json_insert('1', '$[0]', 4);
|
||||
json_insert('1', '$[0]', 4)
|
||||
1
|
||||
select json_replace('1', '$[0]', 4);
|
||||
json_replace('1', '$[0]', 4)
|
||||
4
|
||||
select json_set('1', '$[0]', 4);
|
||||
json_set('1', '$[0]', 4)
|
||||
4
|
||||
select json_set('1', '$[1]', 4);
|
||||
json_set('1', '$[1]', 4)
|
||||
[1, 4]
|
||||
select json_replace('1', '$[1]', 4);
|
||||
json_replace('1', '$[1]', 4)
|
||||
1
|
||||
SELECT json_insert('[]', '$[0][0]', 100);
|
||||
json_insert('[]', '$[0][0]', 100)
|
||||
[]
|
||||
SELECT json_insert('1', '$[0][0]', 100);
|
||||
json_insert('1', '$[0][0]', 100)
|
||||
1
|
||||
SELECT json_replace('1', '$[0][0]', 100);
|
||||
json_replace('1', '$[0][0]', 100)
|
||||
100
|
||||
SELECT json_replace('[]', '$[0][0]', 100);
|
||||
json_replace('[]', '$[0][0]', 100)
|
||||
[]
|
||||
SELECT json_set('[]', '$[0][0]', 100);
|
||||
json_set('[]', '$[0][0]', 100)
|
||||
[]
|
||||
SELECT json_set('[]', '$[0][0][0]', 100);
|
||||
json_set('[]', '$[0][0][0]', 100)
|
||||
[]
|
||||
|
Reference in New Issue
Block a user