1
0
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:
Alexey Botchkov
2017-02-06 06:47:48 +04:00
parent e51b015fc3
commit abf7582112
8 changed files with 639 additions and 220 deletions

View File

@ -710,19 +710,19 @@ Warnings:
Warning 4044 Wildcards in JSON path not allowed in argument 3 to function 'json_remove'
select json_remove( '[ 1, 2, 3 ]', '$[0]' );
json_remove( '[ 1, 2, 3 ]', '$[0]' )
[ 2, 3 ]
[2, 3]
select json_remove( '[ 1, 2, 3 ]', '$[1]' );
json_remove( '[ 1, 2, 3 ]', '$[1]' )
[ 1, 3 ]
[1, 3]
select json_remove( '[ 1, 2, 3 ]', '$[2]' );
json_remove( '[ 1, 2, 3 ]', '$[2]' )
[ 1, 2]
[1, 2]
select json_remove( '[ 1, 2, 3 ]', '$[3]' );
json_remove( '[ 1, 2, 3 ]', '$[3]' )
[ 1, 2, 3 ]
[1, 2, 3]
select json_remove( '[ 1, { "a": true, "b": false, "c": null }, 5 ]', '$[1]' );
json_remove( '[ 1, { "a": true, "b": false, "c": null }, 5 ]', '$[1]' )
[ 1, 5 ]
[1, 5]
error ER_INVALID_JSON_PATH_WILDCARD
select json_remove( '[ { "a": { "a": true } } ]', '$**.a' );
json_remove( '[ { "a": { "a": true } } ]', '$**.a' )
@ -731,7 +731,7 @@ Warnings:
Warning 4044 Wildcards in JSON path not allowed in argument 2 to function 'json_remove'
select json_remove( '[ { "a": true }, { "b": false }, { "c": null }, { "a": null } ]', '$[0].a', '$[2].c' );
json_remove( '[ { "a": true }, { "b": false }, { "c": null }, { "a": null } ]', '$[0].a', '$[2].c' )
[ { }, { "b": false }, { }, { "a": null } ]
[{}, {"b": false}, {}, {"a": null}]
error ER_INVALID_JSON_PATH_WILDCARD
select json_remove( '[ { "a": true }, { "b": [ { "c": { "a": true } } ] }, { "c": null }, { "a": null } ]', '$**.a' );
json_remove( '[ { "a": true }, { "b": [ { "c": { "a": true } } ] }, { "c": null }, { "a": null } ]', '$**.a' )
@ -751,7 +751,7 @@ JSON_REMOVE
'{"a" : "foo", "b" : [true, {"c" : 123}]}',
'$.b[ 1 ]'
)
{"a" : "foo", "b" : [true, {"c" : 123}]}
{"a": "foo", "b": [true]}
SELECT JSON_REMOVE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
@ -762,9 +762,7 @@ JSON_REMOVE
'{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
'$.b[ 1 ].c'
)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_remove'
{"a": "foo", "b": [true, {"c": 456}]}
SELECT JSON_REMOVE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -775,9 +773,7 @@ JSON_REMOVE
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c'
)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_remove'
{"a": "foo", "b": [true, {}]}
SELECT JSON_REMOVE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123, "d" : 456 } ] }',
@ -788,9 +784,7 @@ JSON_REMOVE
'{ "a" : "foo", "b" : [ true, { "c" : 123, "d" : 456 } ] }',
'$.b[ 1 ].e'
)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_remove'
{"a": "foo", "b": [true, {"c": 123, "d": 456}]}
# ----------------------------------------------------------------------
# Test of JSON_MERGE function.
# ----------------------------------------------------------------------
@ -823,7 +817,9 @@ NULL
error ER_INVALID_JSON_TEXT_IN_PARAM
select json_merge( '[1, 2]', '[3, 4' );
json_merge( '[1, 2]', '[3, 4' )
[1, 2, 3, 4
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_merge'
error ER_INVALID_JSON_TEXT_IN_PARAM
select json_merge( '[1, 2', '[3, 4]' );
json_merge( '[1, 2', '[3, 4]' )
@ -841,55 +837,55 @@ json_merge( '[1, 2]', '3' )
[1, 2, 3]
select json_merge( '1', '{ "a": 2 }' );
json_merge( '1', '{ "a": 2 }' )
[1, { "a": 2 }]
[1, {"a": 2}]
select json_merge( '{ "a": 2 }', '1' );
json_merge( '{ "a": 2 }', '1' )
[{ "a": 2 }, 1]
[{"a": 2}, 1]
select json_merge( '[1, 2]', '[3, 4]' );
json_merge( '[1, 2]', '[3, 4]' )
[1, 2, 3, 4]
select json_merge( '{ "a": 2 }', '{ "b": 3}' );
json_merge( '{ "a": 2 }', '{ "b": 3}' )
{ "a": 2 , "b": 3}
{"a": 2, "b": 3}
select json_merge( '[1, 2]', '{ "a": 2 }' );
json_merge( '[1, 2]', '{ "a": 2 }' )
[1, 2, { "a": 2 }]
[1, 2, {"a": 2}]
select json_merge( '{ "a": 2 }', '[1, 2]' );
json_merge( '{ "a": 2 }', '[1, 2]' )
[{ "a": 2 }, 1, 2]
[{"a": 2}, 1, 2]
select json_merge( '{"a": 1, "b": 2 }', '{"b": 3, "d": 4 }' );
json_merge( '{"a": 1, "b": 2 }', '{"b": 3, "d": 4 }' )
{"a": 1, "b": 2 , "b": 3, "d": 4 }
{"a": 1, "b": 2, "b": 3, "d": 4}
select json_merge( '{"a": 1, "b": 2 }', '{"b": [3, 4], "d": 4 }' );
json_merge( '{"a": 1, "b": 2 }', '{"b": [3, 4], "d": 4 }' )
{"a": 1, "b": 2 , "b": [3, 4], "d": 4 }
{"a": 1, "b": 2, "b": [3, 4], "d": 4}
select json_merge( '{"a": 1, "b": [2, 3] }', '{"b": 4, "d": 4 }' );
json_merge( '{"a": 1, "b": [2, 3] }', '{"b": 4, "d": 4 }' )
{"a": 1, "b": [2, 3] , "b": 4, "d": 4 }
{"a": 1, "b": [2, 3], "b": 4, "d": 4}
select json_merge( '{"a": 1, "b": 2 }', '{"b": {"e": 7, "f": 8}, "d": 4 }' );
json_merge( '{"a": 1, "b": 2 }', '{"b": {"e": 7, "f": 8}, "d": 4 }' )
{"a": 1, "b": 2 , "b": {"e": 7, "f": 8}, "d": 4 }
{"a": 1, "b": 2, "b": {"e": 7, "f": 8}, "d": 4}
select json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{"a": 1, "b": 2 }' );
json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{"a": 1, "b": 2 }' )
{"b": {"e": 7, "f": 8}, "d": 4 , "a": 1, "b": 2 }
{"b": {"e": 7, "f": 8}, "d": 4, "a": 1, "b": 2}
select json_merge( '{"a": 1, "b": [2, 9] }', '{"b": [10, 11], "d": 4 }' );
json_merge( '{"a": 1, "b": [2, 9] }', '{"b": [10, 11], "d": 4 }' )
{"a": 1, "b": [2, 9] , "b": [10, 11], "d": 4 }
{"a": 1, "b": [2, 9], "b": [10, 11], "d": 4}
select json_merge( '{"a": 1, "b": [2, 9] }', '{"b": {"e": 7, "f": 8}, "d": 4 }' );
json_merge( '{"a": 1, "b": [2, 9] }', '{"b": {"e": 7, "f": 8}, "d": 4 }' )
{"a": 1, "b": [2, 9] , "b": {"e": 7, "f": 8}, "d": 4 }
{"a": 1, "b": [2, 9], "b": {"e": 7, "f": 8}, "d": 4}
select json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{"a": 1, "b": [2, 9] }' );
json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{"a": 1, "b": [2, 9] }' )
{"b": {"e": 7, "f": 8}, "d": 4 , "a": 1, "b": [2, 9] }
{"b": {"e": 7, "f": 8}, "d": 4, "a": 1, "b": [2, 9]}
select json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{ "a": 1, "b": {"e": 20, "g": 21 } }' );
json_merge( '{"b": {"e": 7, "f": 8}, "d": 4 }', '{ "a": 1, "b": {"e": 20, "g": 21 } }' )
{"b": {"e": 7, "f": 8}, "d": 4 , "a": 1, "b": {"e": 20, "g": 21 } }
{"b": {"e": 7, "f": 8}, "d": 4, "a": 1, "b": {"e": 20, "g": 21}}
select json_merge( '1', '2', '3' );
json_merge( '1', '2', '3' )
[1, 2, 3]
select json_merge( '[1, 2 ]', '3', '[4, 5]' );
json_merge( '[1, 2 ]', '3', '[4, 5]' )
[1, 2 , 3, 4, 5]
[1, 2, 3, 4, 5]
select json_merge
(
'{ "a": true, "b": { "c": 3, "d": 4 }, "e": [ 1, 2 ] }',
@ -902,7 +898,7 @@ json_merge
'{ "d": false, "b": { "g": 3, "d": 5 }, "f": [ 1, 2 ] }',
'{ "m": true, "b": { "h": 8, "d": 4 }, "e": [ 3, 4 ] }'
)
{ "a": true, "b": { "c": 3, "d": 4 }, "e": [ 1, 2 ] , "d": false, "b": { "g": 3, "d": 5 }, "f": [ 1, 2 ] , "m": true, "b": { "h": 8, "d": 4 }, "e": [ 3, 4 ] }
{"a": true, "b": {"c": 3, "d": 4}, "e": [1, 2], "d": false, "b": {"g": 3, "d": 5}, "f": [1, 2], "m": true, "b": {"h": 8, "d": 4}, "e": [3, 4]}
SELECT JSON_MERGE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -913,7 +909,7 @@ JSON_MERGE
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'[ 5, 6]'
)
[{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }, 5, 6]
[{"a": "foo", "b": [true, {"c": 123}]}, 5, 6]
SELECT JSON_MERGE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -924,7 +920,7 @@ JSON_MERGE
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'{ "b": [ false, 34 ] }'
)
{ "a" : "foo", "b" : [ true, { "c" : 123 } ] , "b": [ false, 34 ] }
{"a": "foo", "b": [true, {"c": 123}], "b": [false, 34]}
SELECT JSON_MERGE
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -935,7 +931,7 @@ JSON_MERGE
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'{ "b": "bar" }'
)
{ "a" : "foo", "b" : [ true, { "c" : 123 } ] , "b": "bar" }
{"a": "foo", "b": [true, {"c": 123}], "b": "bar"}
SELECT JSON_MERGE
(
'{ "a" : { "b" : 1 } }',
@ -946,7 +942,7 @@ JSON_MERGE
'{ "a" : { "b" : 1 } }',
'{ "a" : { "c" : 1 } }'
)
{ "a" : { "b" : 1 } , "a" : { "c" : 1 } }
{"a": {"b": 1}, "a": {"c": 1}}
# ----------------------------------------------------------------------
# Test of JSON_TYPE function.
# ----------------------------------------------------------------------
@ -1296,16 +1292,16 @@ json_extract( '{ "a": 1}', '$.a' )
1
select json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[0]' );
json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[0]' )
[ 3, 2 ]
[3, 2]
select json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[0][1]' );
json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[0][1]' )
2
select json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1]' );
json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1]' )
[ { "c" : "d" }, 1 ]
[{"c": "d"}, 1]
select json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1][0]' );
json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1][0]' )
{ "c" : "d" }
{"c": "d"}
select json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1][0].c' );
json_extract( '{ "a": [ [ 3, 2 ], [ { "c" : "d" }, 1 ] ], "b": { "c" : 6 }, "one potato": 7, "b.c" : 8 }', '$.a[1][0].c' )
"d"
@ -1359,13 +1355,13 @@ SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : "123" } ] }',
'$.b[ 1 ].c');
JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : "123" } ] }',
'$.b[ 1 ].c')
NULL
"123"
# returns a JSON value containing just the number 123
SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c');
JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c')
NULL
123
# raises an error because the document is not valid
error ER_INVALID_JSON_TEXT_IN_PARAM
SELECT JSON_EXTRACT('{ "a" : [ }',
@ -1390,13 +1386,13 @@ SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c[ 0 ]');
JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c[ 0 ]')
NULL
123
# returns a JSON value containing the object because of auto-wrapping
SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : {"not array": 4} } ] }',
'$.b[ 1 ].c[ 0 ]');
JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : {"not array": 4} } ] }',
'$.b[ 1 ].c[ 0 ]')
NULL
{"not array": 4}
# returns null because the path, although valid, does not identify a value
SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c[ 1 ]');
@ -1408,7 +1404,7 @@ SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
'$.b[ 1 ].c');
JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
'$.b[ 1 ].c')
NULL
123
# returns a JSON array [ "foo", true ]
SELECT JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
'$.a', '$.b[0]');
@ -1423,48 +1419,48 @@ JSON_EXTRACT('{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
[true]
select json_extract( '[1]', '$[0][0]' );
json_extract( '[1]', '$[0][0]' )
NULL
1
select json_extract( '[1]', '$**[0]' );
json_extract( '[1]', '$**[0]' )
[1]
select json_extract( '{ "a": 1 }', '$.a[0]' );
json_extract( '{ "a": 1 }', '$.a[0]' )
NULL
1
select json_extract( '{ "a": 1 }', '$**[0]' );
json_extract( '{ "a": 1 }', '$**[0]' )
NULL
[{"a": 1}, 1]
select json_extract( '{ "a": 1 }', '$[0].a' );
json_extract( '{ "a": 1 }', '$[0].a' )
NULL
1
select json_extract( '{ "a": 1 }', '$**.a' );
json_extract( '{ "a": 1 }', '$**.a' )
[1]
select json_extract( '{ "a": 1 }', '$[0].a[0]' );
json_extract( '{ "a": 1 }', '$[0].a[0]' )
NULL
1
select json_extract( '{ "a": 1 }', '$**[0]' );
json_extract( '{ "a": 1 }', '$**[0]' )
NULL
[{"a": 1}, 1]
select json_extract( '{ "a": 1 }', '$[0].a' );
json_extract( '{ "a": 1 }', '$[0].a' )
NULL
1
select json_extract( '{ "a": 1 }', '$**.a' );
json_extract( '{ "a": 1 }', '$**.a' )
[1]
select json_extract( '{ "a": 1 }', '$[0][0].a' );
json_extract( '{ "a": 1 }', '$[0][0].a' )
NULL
1
select json_extract( '{ "a": 1 }', '$[0][0][0].a' );
json_extract( '{ "a": 1 }', '$[0][0][0].a' )
NULL
1
SELECT JSON_EXTRACT('[1, [[{"x": [{"a":{"b":{"c":42}}}]}]]]', '$**.a.*');
JSON_EXTRACT('[1, [[{"x": [{"a":{"b":{"c":42}}}]}]]]', '$**.a.*')
[{"c":42}]
[{"c": 42}]
SELECT JSON_EXTRACT('[1, [[{"x": [{"a":{"b":{"c":42}}}]}]]]',
'$[1][0][0].x[0].a.*');
JSON_EXTRACT('[1, [[{"x": [{"a":{"b":{"c":42}}}]}]]]',
'$[1][0][0].x[0].a.*')
[{"c":42}]
[{"c": 42}]
SELECT JSON_EXTRACT
(
'{ "a" : "foo", "b" : [ true, { "c" : "123" } ] }',
@ -1475,7 +1471,7 @@ JSON_EXTRACT
'{ "a" : "foo", "b" : [ true, { "c" : "123" } ] }',
'$.b[ 1 ].c'
)
NULL
"123"
SELECT JSON_EXTRACT
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -1486,7 +1482,7 @@ JSON_EXTRACT
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c'
)
NULL
123
error ER_INVALID_JSON_TEXT_IN_PARAM
SELECT JSON_EXTRACT
(
@ -1525,7 +1521,7 @@ JSON_EXTRACT
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
'$.b[ 1 ].c[ 0 ]'
)
NULL
123
SELECT JSON_EXTRACT
(
'{ "a" : "foo", "b" : [ true, { "c" : 123 } ] }',
@ -1547,7 +1543,7 @@ JSON_EXTRACT
'{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
'$.b[ 1 ].c'
)
NULL
123
SELECT JSON_EXTRACT
(
'{ "a" : "foo", "b" : [ true, { "c" : 123, "c" : 456 } ] }',
@ -1587,13 +1583,13 @@ jdoc
[1]
select json_extract( '[ { "a": [3,4] }, { "b": 2 } ]', '$[0].a' ) jdoc;
jdoc
[3,4]
[3, 4]
select json_extract( '[ { "a": [3,4] }, { "b": 2 } ]', '$[*].a' ) jdoc;
jdoc
[[3,4]]
[[3, 4]]
select json_extract( '[ { "a": [3,4] }, { "b": 2 } ]', '$[0].a', '$[1].a' ) jdoc;
jdoc
[[3,4]]
[[3, 4]]
# ----------------------------------------------------------------------
# Test of JSON_ARRAY_APPEND function.
# ----------------------------------------------------------------------
@ -1605,7 +1601,7 @@ json_array_append('[1,2,3]', NULL, cast(1 as json))
NULL
select json_array_append('[1,2,3]', '$', NULL);
json_array_append('[1,2,3]', '$', NULL)
[1,2,3, null]
[1, 2, 3, null]
select json_array_append(NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_array_append'
select json_array_append(NULL, NULL);
@ -1641,14 +1637,14 @@ SELECT JSON_ARRAY_APPEND('{"a" : "foo","b": [1, 2, 3], "c": ["apple", "pear"]}',
JSON_ARRAY_APPEND('{"a" : "foo","b": [1, 2, 3], "c": ["apple", "pear"]}',
'$.b', cast(4 as json),
'$.c', cast('"grape"' as json))
{"a" : "foo","b": [1, 2, 3, 4], "c": ["apple", "pear", "grape"]}
{"a": "foo", "b": [1, 2, 3, 4], "c": ["apple", "pear", "grape"]}
SELECT JSON_ARRAY_APPEND('{"a" : "foo","b": [1, 2, 3], "c": ["apple", "pear"]}',
'$.b', 4,
'$.c', 'grape');
JSON_ARRAY_APPEND('{"a" : "foo","b": [1, 2, 3], "c": ["apple", "pear"]}',
'$.b', 4,
'$.c', 'grape')
{"a" : "foo","b": [1, 2, 3, 4], "c": ["apple", "pear", "grape"]}
{"a": "foo", "b": [1, 2, 3, 4], "c": ["apple", "pear", "grape"]}
error ER_INVALID_JSON_PATH_WILDCARD
select json_array_append( '[[], [], []]', '$[*]', 3, '$[*]', 4);
json_array_append( '[[], [], []]', '$[*]', 3, '$[*]', 4)
@ -1673,7 +1669,7 @@ JSON_ARRAY_APPEND
'$.b', 4,
'$.c', "grape"
)
{ "a" : "foo", "b" : ["bar", 4], "c" : ["wibble", "grape"] }
{"a": "foo", "b": ["bar", 4], "c": ["wibble", "grape"]}
SELECT JSON_ARRAY_APPEND
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ], "c" : [ "apple", "pear" ] }',
@ -1686,13 +1682,13 @@ JSON_ARRAY_APPEND
'$.b', 4,
'$.c', "grape"
)
{ "a" : "foo", "b" : [ 1, 2, 3 , 4], "c" : [ "apple", "pear" , "grape"] }
{"a": "foo", "b": [1, 2, 3, 4], "c": ["apple", "pear", "grape"]}
# ----------------------------------------------------------------------
# Bug#21373874 ASSERTION `PARENT' FAILED
# ----------------------------------------------------------------------
select json_array_append('{"a":1}', '$[0]', 100);
json_array_append('{"a":1}', '$[0]', 100)
[{"a":1}, 100]
[{"a": 1}, 100]
select json_array_append('3', '$[0]', 100);
json_array_append('3', '$[0]', 100)
[3, 100]
@ -1710,7 +1706,7 @@ json_insert('[1,2,3]', NULL, cast(1 as json))
NULL
select json_insert('[1,2,3]', '$[3]', NULL);
json_insert('[1,2,3]', '$[3]', NULL)
[1,2,3, null]
[1, 2, 3, null]
select json_insert(NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_insert'
select json_insert(NULL, NULL);
@ -1719,25 +1715,25 @@ select json_insert(NULL, NULL, NULL, NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_insert'
select json_insert('[1,2,3]', '$[2]', 4);
json_insert('[1,2,3]', '$[2]', 4)
[1,2,3]
[1, 2, 3]
select json_insert('[1,2,3]', '$[3]', 4);
json_insert('[1,2,3]', '$[3]', 4)
[1,2,3, 4]
[1, 2, 3, 4]
select json_insert('[1,2,3]', '$[10]', 4);
json_insert('[1,2,3]', '$[10]', 4)
[1,2,3, 4]
[1, 2, 3, 4]
select json_insert('{"c":4}', '$.c', 4);
json_insert('{"c":4}', '$.c', 4)
{"c":4}
{"c": 4}
select json_insert('{"c":4}', '$.a', 4);
json_insert('{"c":4}', '$.a', 4)
{"c":4, "a":4}
{"c": 4, "a": 4}
select json_insert('1', '$', 4);
json_insert('1', '$', 4)
1
select json_insert('1', '$[0]', 4);
json_insert('1', '$[0]', 4)
[1, 4]
1
select json_insert('1', '$[1]', 4);
json_insert('1', '$[1]', 4)
[1, 4]
@ -1746,13 +1742,13 @@ json_insert('1', '$[10]', '4', '$[11]', 5)
[1, "4", 5]
select json_insert('[1,2,3]', '$[2][0]', 4);
json_insert('[1,2,3]', '$[2][0]', 4)
[1,2,[3, 4]]
[1, 2, 3]
select json_insert('[1,2,3]', '$[2][2]', 4);
json_insert('[1,2,3]', '$[2][2]', 4)
[1,2,[3, 4]]
[1, 2, [3, 4]]
select json_insert('{"a": 3}', '$.a[0]', 4);
json_insert('{"a": 3}', '$.a[0]', 4)
{"a": [3, 4]}
{"a": 3}
select json_insert('{"a": 3}', '$.a[1]', 4, '$.a[2]', '5');
json_insert('{"a": 3}', '$.a[1]', 4, '$.a[2]', '5')
{"a": [3, 4, "5"]}
@ -1833,19 +1829,19 @@ json_insert(cast('{"a": 3}' as json), '$[1]', 6)
[{"a": 3}, 6]
SELECT JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.a', true);
JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.a', true)
{ "a" : "foo", "b" : [ 1, 2, 3 ] }
{"a": "foo", "b": [1, 2, 3]}
SELECT JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.c', 123);
JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.c', 123)
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":123}
{"a": "foo", "b": [1, 2, 3], "c": 123}
SELECT JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.c', '123');
JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.c', '123')
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":"123"}
{"a": "foo", "b": [1, 2, 3], "c": "123"}
SELECT JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.a[1]', true);
JSON_INSERT('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.a[1]', true)
{ "a" : ["foo", true], "b" : [ 1, 2, 3 ] }
{"a": ["foo", true], "b": [1, 2, 3]}
SELECT JSON_INSERT('{ "a" : "foo"}', '$.b', true, '$.b', false);
JSON_INSERT('{ "a" : "foo"}', '$.b', true, '$.b', false)
{ "a" : "foo", "b":true}
{"a": "foo", "b": true}
SELECT JSON_INSERT
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -1858,7 +1854,7 @@ JSON_INSERT
'$.a',
true
)
{ "a" : "foo", "b" : [ 1, 2, 3 ] }
{"a": "foo", "b": [1, 2, 3]}
SELECT JSON_INSERT
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -1871,7 +1867,7 @@ JSON_INSERT
'$.c',
123
)
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":123}
{"a": "foo", "b": [1, 2, 3], "c": 123}
SELECT JSON_INSERT
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -1884,7 +1880,7 @@ JSON_INSERT
'$.c',
'123'
)
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":"123"}
{"a": "foo", "b": [1, 2, 3], "c": "123"}
SELECT JSON_INSERT
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -1897,7 +1893,7 @@ JSON_INSERT
'$.a[1]',
true
)
{ "a" : ["foo", true], "b" : [ 1, 2, 3 ] }
{"a": ["foo", true], "b": [1, 2, 3]}
SELECT JSON_INSERT
(
'{ "a" : "foo"}',
@ -1910,7 +1906,7 @@ JSON_INSERT
'$.b', true,
'$.b', false
)
{ "a" : "foo", "b":true}
{"a": "foo", "b": true}
# ----------------------------------------------------------------------
# Test of JSON_ARRAY_INSERT function.
# ----------------------------------------------------------------------
@ -1922,7 +1918,7 @@ json_array_insert('[1,2,3]', NULL, 1)
NULL
select json_array_insert('[1,2,3]', '$[3]', NULL);
json_array_insert('[1,2,3]', '$[3]', NULL)
[1,2,3, null]
[1, 2, 3, null]
select json_array_insert(NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_array_insert'
select json_array_insert(NULL, NULL);
@ -1949,10 +1945,10 @@ json_array_insert( 'true', '$[1]', false )
true
select json_array_insert( '{ "a": true }', '$.a[0]', false );
json_array_insert( '{ "a": true }', '$.a[0]', false )
{ "a": true }
{"a": true}
select json_array_insert( '{ "a": true }', '$.a[1]', false );
json_array_insert( '{ "a": true }', '$.a[1]', false )
{ "a": true }
{"a": true}
select json_array_insert( '[]', '$[0]', false );
json_array_insert( '[]', '$[0]', false )
[false]
@ -1970,19 +1966,19 @@ json_array_insert( '[true]', '$[2]', false )
[true, false]
select json_array_insert( '{ "a": [] }', '$.a[0]', false );
json_array_insert( '{ "a": [] }', '$.a[0]', false )
{ "a": [false] }
{"a": [false]}
select json_array_insert( '{ "a": [] }', '$.a[1]', false );
json_array_insert( '{ "a": [] }', '$.a[1]', false )
{ "a": [false] }
{"a": [false]}
select json_array_insert( '{ "a": [true] }', '$.a[0]', false );
json_array_insert( '{ "a": [true] }', '$.a[0]', false )
{ "a": [false, true] }
{"a": [false, true]}
select json_array_insert( '{ "a": [true] }', '$.a[1]', false );
json_array_insert( '{ "a": [true] }', '$.a[1]', false )
{ "a": [true, false] }
{"a": [true, false]}
select json_array_insert( '{ "a": [true] }', '$.a[2]', false );
json_array_insert( '{ "a": [true] }', '$.a[2]', false )
{ "a": [true, false] }
{"a": [true, false]}
select json_array_insert( '[1, 2, 3, 4]', '$[0]', false );
json_array_insert( '[1, 2, 3, 4]', '$[0]', false )
[false, 1, 2, 3, 4]
@ -2003,34 +1999,34 @@ json_array_insert( '[1, 2, 3, 4]', '$[5]', false )
[1, 2, 3, 4, false]
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[0]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[0]', false )
{ "a": [false, 1, 2, 3, 4] }
{"a": [false, 1, 2, 3, 4]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[1]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[1]', false )
{ "a": [1, false, 2, 3, 4] }
{"a": [1, false, 2, 3, 4]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[2]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[2]', false )
{ "a": [1, 2, false, 3, 4] }
{"a": [1, 2, false, 3, 4]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[3]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[3]', false )
{ "a": [1, 2, 3, false, 4] }
{"a": [1, 2, 3, false, 4]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[4]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[4]', false )
{ "a": [1, 2, 3, 4, false] }
{"a": [1, 2, 3, 4, false]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[5]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.a[5]', false )
{ "a": [1, 2, 3, 4, false] }
{"a": [1, 2, 3, 4, false]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.b[0]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.b[0]', false )
{ "a": [1, 2, 3, 4] }
{"a": [1, 2, 3, 4]}
select json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.b[1]', false );
json_array_insert( '{ "a": [1, 2, 3, 4] }', '$.b[1]', false )
{ "a": [1, 2, 3, 4] }
{"a": [1, 2, 3, 4]}
select json_array_insert( '"a"', '$[0]', true );
json_array_insert( '"a"', '$[0]', true )
"a"
select json_array_insert( '[ "a" ]', '$[0][0]', true );
json_array_insert( '[ "a" ]', '$[0][0]', true )
[ "a" ]
["a"]
select json_array_insert( '"a"', '$[1]', true );
json_array_insert( '"a"', '$[1]', true )
"a"
@ -2054,12 +2050,12 @@ Warnings:
Warning 4044 Wildcards in JSON path not allowed in argument 2 to function 'json_insert'
select json_array_insert( '[ 1, 2, 3 ]', '$[1]', true, '$[1]', false );
json_array_insert( '[ 1, 2, 3 ]', '$[1]', true, '$[1]', false )
[ 1, false, true, 2, 3 ]
[1, false, true, 2, 3]
select json_array_insert( '[ 1, 2, 3 ]', '$[1]',
cast( '[ "a", "b", "c", "d" ]' as json ), '$[1][2]', false );
json_array_insert( '[ 1, 2, 3 ]', '$[1]',
cast( '[ "a", "b", "c", "d" ]' as json ), '$[1][2]', false )
[ 1, [ "a", "b", false, "c", "d" ], 2, 3 ]
[1, ["a", "b", false, "c", "d"], 2, 3]
error ER_INVALID_JSON_TEXT_IN_PARAM
SELECT JSON_ARRAY_INSERT(JSON_EXTRACT('[1', '$'), '$[0]', 1);
JSON_ARRAY_INSERT(JSON_EXTRACT('[1', '$'), '$[0]', 1)
@ -2069,7 +2065,7 @@ Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_extract
error ER_INVALID_JSON_TEXT_IN_PARAM
select json_array_insert( '[ 1, 2, 3 ]', '$[1]', json_extract( '[', '$' ) );
json_array_insert( '[ 1, 2, 3 ]', '$[1]', json_extract( '[', '$' ) )
[ 1, null, 2, 3 ]
[1, null, 2, 3]
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_extract'
# ----------------------------------------------------------------------
@ -2083,7 +2079,7 @@ json_set('[1,2,3]', NULL, cast(1 as json))
NULL
select json_set('[1,2,3]', '$[3]', NULL);
json_set('[1,2,3]', '$[3]', NULL)
[1,2,3, null]
[1, 2, 3, null]
select json_set(NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_set'
select json_set(NULL, NULL);
@ -2093,24 +2089,25 @@ ERROR 42000: Incorrect parameter count in the call to native function 'json_set'
error ER_INVALID_JSON_TEXT_IN_PARAM
SELECT JSON_SET('{}', '$.name', JSON_EXTRACT('', '$'));
JSON_SET('{}', '$.name', JSON_EXTRACT('', '$'))
{, "name":null}
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_extract'
Warning 4038 Syntax error in JSON text in argument 1 to function 'json_set' at position 2
select json_set('[1,2,3]', '$[2]', 4);
json_set('[1,2,3]', '$[2]', 4)
[1,2,4]
[1, 2, 4]
select json_set('[1,2,3]', '$[3]', 4);
json_set('[1,2,3]', '$[3]', 4)
[1,2,3, 4]
[1, 2, 3, 4]
select json_set('[1,2,3]', '$[10]', 4);
json_set('[1,2,3]', '$[10]', 4)
[1,2,3, 4]
[1, 2, 3, 4]
select json_set('{"c":4}', '$.c', 5);
json_set('{"c":4}', '$.c', 5)
{"c":5}
{"c": 5}
select json_set('{"c":4}', '$.a', 5);
json_set('{"c":4}', '$.a', 5)
{"c":4, "a":5}
{"c": 4, "a": 5}
select json_set('1', '$', 4);
json_set('1', '$', 4)
4
@ -2125,10 +2122,10 @@ json_set('1', '$[10]', '4', '$[11]', 5)
[1, "4", 5]
select json_set('[1,2,3]', '$[2][0]', 4);
json_set('[1,2,3]', '$[2][0]', 4)
[1,2,4]
[1, 2, 4]
select json_set('[1,2,3]', '$[2][2]', 4);
json_set('[1,2,3]', '$[2][2]', 4)
[1,2,[3, 4]]
[1, 2, [3, 4]]
select json_set('{"a": 3}', '$.a[0]', 4);
json_set('{"a": 3}', '$.a[0]', 4)
{"a": 4}
@ -2147,26 +2144,26 @@ JSON_OBJECT());
JSON_SET('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.a',
JSON_OBJECT())
{ "a" : {}, "b" : [ 1, 2, 3 ] }
{"a": {}, "b": [1, 2, 3]}
SELECT JSON_SET('{ "a" : "foo"}', '$.a',
JSON_OBJECT( 'b', false ), '$.a.c', true);
JSON_SET('{ "a" : "foo"}', '$.a',
JSON_OBJECT( 'b', false ), '$.a.c', true)
{ "a" : {"b": false, "c":true}}
{"a": {"b": false, "c": true}}
select json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.a',
cast('{}' as json));
json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.a',
cast('{}' as json))
{ "a" : {}, "b" : [ 1, 2, 3 ] }
{"a": {}, "b": [1, 2, 3]}
select json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.c',
cast('[true, false]' as json));
json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.c',
cast('[true, false]' as json))
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":[true, false]}
{"a": "foo", "b": [1, 2, 3], "c": [true, false]}
select json_set('1', '$[3]', 2);
json_set('1', '$[3]', 2)
[1, 2]
@ -2174,7 +2171,7 @@ select json_set('{ "a" : "foo"}', '$.a',
cast('{"b": false}' as json), '$.a.c', true);
json_set('{ "a" : "foo"}', '$.a',
cast('{"b": false}' as json), '$.a.c', true)
{ "a" : {"b": false, "c":true}}
{"a": {"b": false, "c": true}}
SELECT JSON_SET
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -2187,7 +2184,7 @@ JSON_SET
'$.a',
JSON_OBJECT()
)
{ "a" : {}, "b" : [ 1, 2, 3 ] }
{"a": {}, "b": [1, 2, 3]}
SELECT JSON_SET
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -2200,7 +2197,7 @@ JSON_SET
'$.c',
JSON_ARRAY( true, false )
)
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":[true, false]}
{"a": "foo", "b": [1, 2, 3], "c": [true, false]}
SELECT JSON_SET
(
'{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
@ -2213,7 +2210,7 @@ JSON_SET
'$.c',
JSON_ARRAY( CAST( 'true' AS JSON ), CAST( 'false' AS JSON ) )
)
{ "a" : "foo", "b" : [ 1, 2, 3 ] , "c":[true, false]}
{"a": "foo", "b": [1, 2, 3], "c": [true, false]}
SELECT JSON_SET
(
'1',
@ -2239,7 +2236,7 @@ JSON_SET
'$.a', JSON_OBJECT( 'b', false ),
'$.a.c', true
)
{ "a" : {"b": false, "c":true}}
{"a": {"b": false, "c": true}}
# ----------------------------------------------------------------------
# Test of JSON_REPLACE function.
# ----------------------------------------------------------------------
@ -2251,7 +2248,7 @@ json_replace('[1,2,3]', NULL, cast(1 as json))
NULL
select json_replace('[1,2,3]', '$[2]', NULL);
json_replace('[1,2,3]', '$[2]', NULL)
[1,2,null]
[1, 2, null]
select json_replace(NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_replace'
select json_replace(NULL, NULL);
@ -2260,19 +2257,19 @@ select json_replace(NULL, NULL, NULL, NULL);
ERROR 42000: Incorrect parameter count in the call to native function 'json_replace'
select json_replace('[1,2,3]', '$[2]', 4);
json_replace('[1,2,3]', '$[2]', 4)
[1,2,4]
[1, 2, 4]
select json_replace('[1,2,3]', '$[3]', 4);
json_replace('[1,2,3]', '$[3]', 4)
[1,2,3]
[1, 2, 3]
select json_replace('[1,2,3]', '$[10]', 4);
json_replace('[1,2,3]', '$[10]', 4)
[1,2,3]
[1, 2, 3]
select json_replace('{"c":4}', '$.c', 5);
json_replace('{"c":4}', '$.c', 5)
{"c":5}
{"c": 5}
select json_replace('{"c":4}', '$.a', 5);
json_replace('{"c":4}', '$.a', 5)
{"c":4}
{"c": 4}
select json_replace('1', '$', 4);
json_replace('1', '$', 4)
4
@ -2287,10 +2284,10 @@ json_replace('1', '$[10]', '4', '$[11]', 5)
1
select json_replace('[1,2,3]', '$[2][0]', 4);
json_replace('[1,2,3]', '$[2][0]', 4)
[1,2,4]
[1, 2, 4]
select json_replace('[1,2,3]', '$[2][2]', 4);
json_replace('[1,2,3]', '$[2][2]', 4)
[1,2,3]
[1, 2, 3]
select json_replace('{"a": 3}', '$.a[0]', 4);
json_replace('{"a": 3}', '$.a[0]', 4)
{"a": 4}
@ -2303,21 +2300,21 @@ true);
JSON_REPLACE('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.c',
true)
{ "a" : "foo", "b" : [ 1, 2, 3 ] }
{"a": "foo", "b": [1, 2, 3]}
SELECT JSON_REPLACE('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.a[0]',
true);
JSON_REPLACE('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.a[0]',
true)
{ "a" : true, "b" : [ 1, 2, 3 ] }
{"a": true, "b": [1, 2, 3]}
SELECT JSON_REPLACE('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.b[5]',
true);
JSON_REPLACE('{ "a" : "foo", "b" : [ 1, 2, 3 ] }',
'$.b[5]',
true)
{ "a" : "foo", "b" : [ 1, 2, 3 ] }
{"a": "foo", "b": [1, 2, 3]}
# ----------------------------------------------------------------------
# Test of JSON_ARRAY function.
# ----------------------------------------------------------------------
@ -3231,38 +3228,38 @@ prepare json_stmt5 FROM 'select json_array_append( ''{ "keyA": [1, 2], "keyB": [
set @mypath = '$.keyA';
execute json_stmt5 USING @mypath;
json_array_append( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2, 5], "keyB": [3, 4] }
{"keyA": [1, 2, 5], "keyB": [3, 4]}
set @mypath = '$.keyB';
execute json_stmt5 USING @mypath;
json_array_append( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2], "keyB": [3, 4, 5] }
{"keyA": [1, 2], "keyB": [3, 4, 5]}
prepare json_stmt6 FROM 'select json_insert( ''{ "keyA": [1, 2], "keyB": [3, 4] }'', ?, 5 )';
set @mypath = '$.keyA[2]';
execute json_stmt6 USING @mypath;
json_insert( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2, 5], "keyB": [3, 4] }
{"keyA": [1, 2, 5], "keyB": [3, 4]}
set @mypath = '$.keyB[2]';
execute json_stmt6 USING @mypath;
json_insert( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2], "keyB": [3, 4, 5] }
{"keyA": [1, 2], "keyB": [3, 4, 5]}
prepare json_stmt7 FROM 'select json_set( ''{ "keyA": [1, 2], "keyB": [3, 4] }'', ?, 5 )';
set @mypath = '$.keyA[2]';
execute json_stmt7 USING @mypath;
json_set( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2, 5], "keyB": [3, 4] }
{"keyA": [1, 2, 5], "keyB": [3, 4]}
set @mypath = '$.keyB[2]';
execute json_stmt7 USING @mypath;
json_set( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2], "keyB": [3, 4, 5] }
{"keyA": [1, 2], "keyB": [3, 4, 5]}
prepare json_stmt8 FROM 'select json_replace( ''{ "keyA": [1, 2], "keyB": [3, 4] }'', ?, 5 )';
set @mypath = '$.keyA[1]';
execute json_stmt8 USING @mypath;
json_replace( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 5], "keyB": [3, 4] }
{"keyA": [1, 5], "keyB": [3, 4]}
set @mypath = '$.keyB[1]';
execute json_stmt8 USING @mypath;
json_replace( '{ "keyA": [1, 2], "keyB": [3, 4] }', ?, 5 )
{ "keyA": [1, 2], "keyB": [3, 5] }
{"keyA": [1, 2], "keyB": [3, 5]}
prepare json_stmt9 FROM 'select json_search( ''{ "keyA": [ "foot" ], "keyB": [ "food" ] }'', ''all'', ''foo%'', null, ? )';
set @mypath = '$.keyA';
execute json_stmt9 USING @mypath;
@ -3276,11 +3273,11 @@ prepare json_stmt10 FROM 'select json_remove( ''{ "keyA": [ "foot" ], "keyB": [
set @mypath = '$.keyA';
execute json_stmt10 USING @mypath;
json_remove( '{ "keyA": [ "foot" ], "keyB": [ "food" ] }', ? )
{ "keyB": [ "food" ] }
{"keyB": ["food"]}
set @mypath = '$.keyB';
execute json_stmt10 USING @mypath;
json_remove( '{ "keyA": [ "foot" ], "keyB": [ "food" ] }', ? )
{ "keyA": [ "foot" ]}
{"keyA": ["foot"]}
prepare json_stmt11 FROM 'select json_contains_path( ''{ "keyA": true }'', ?, ''$.keyA'', ''$.keyB'' )';
set @mypath = 'one';
execute json_stmt11 USING @mypath;
@ -3502,14 +3499,10 @@ JSON_SET('[]', '$[0]', 100)
[100]
SELECT JSON_SET('[]', '$[0][0]', 100);
JSON_SET('[]', '$[0][0]', 100)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_set'
[]
SELECT JSON_SET('[]', '$[0][0][0]', 100);
JSON_SET('[]', '$[0][0][0]', 100)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_set'
[]
SELECT JSON_SET('[1]', '$', 100);
JSON_SET('[1]', '$', 100)
100
@ -3566,14 +3559,10 @@ JSON_REPLACE('[]', '$[0]', 100)
[]
SELECT JSON_REPLACE('[]', '$[0][0]', 100);
JSON_REPLACE('[]', '$[0][0]', 100)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_update'
[]
SELECT JSON_REPLACE('[]', '$[0][0][0]', 100);
JSON_REPLACE('[]', '$[0][0][0]', 100)
NULL
Warnings:
Warning 4037 Unexpected end of JSON text in argument 1 to function 'json_update'
[]
SELECT JSON_REPLACE('[1]', '$', 100);
JSON_REPLACE('[1]', '$', 100)
100