mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
75a51818b2
Test case added.
131 lines
5.2 KiB
Text
131 lines
5.2 KiB
Text
select json_valid('[1, 2]');
|
|
select json_valid('"string"}');
|
|
select json_valid('{"key1":1, "key2":[2,3]}');
|
|
select json_valid('[false, true, null]');
|
|
select json_valid(repeat('[', 1000));
|
|
select json_valid(repeat('{"a":', 1000));
|
|
|
|
select json_value('{"key1":123}', '$.key2');
|
|
select json_value('{"key1":123}', '$.key1');
|
|
select json_value('{"key1":[1,2,3]}', '$.key1');
|
|
select json_value('{"key1": [1,2,3], "key1":123}', '$.key1');
|
|
|
|
select json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key2');
|
|
select json_query('{"key1":{"a":1, "b":[1,2]}}', '$.key1');
|
|
select json_query('{"key1": 1}', '$.key1');
|
|
select json_query('{"key1":123, "key1": [1,2,3]}', '$.key1');
|
|
|
|
select json_array();
|
|
select json_array(1);
|
|
select json_array(1, "text", false, null);
|
|
|
|
select json_array_append('["a", "b"]', '$', FALSE);
|
|
select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2);
|
|
select json_array_append('["a", ["b", "c"], "d"]', '$[0]', 2);
|
|
|
|
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1]', 'x');
|
|
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[2]', 'x');
|
|
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[3]', 'x');
|
|
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[4]', 'x');
|
|
select json_array_insert('["a", {"b": [1, 2]}, [3, 4]]', '$[1].b[0]', 'x');
|
|
select json_array_insert('true', '$', 1);
|
|
|
|
select json_contains('{"k1":123, "k2":345}', '123', '$.k1');
|
|
select json_contains('"you"', '"you"');
|
|
select json_contains('"youth"', '"you"');
|
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
|
select json_contains('[1]', '[1]', '$', '$[0]');
|
|
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[10]");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.ma");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "one", "$.key1", "$.ma");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.ma");
|
|
select json_contains_path('{"key1":1, "key2":[2,3]}', "aLl", "$.key1", "$.key2");
|
|
select json_contains_path('{ "a": true }', NULL, '$.a' );
|
|
select json_contains_path('{ "a": true }', 'all', NULL );
|
|
|
|
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1");
|
|
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.keyX", "$.keyY");
|
|
select json_extract('{"key1":"asd", "key2":[2,3]}', "$.key1", "$.key2");
|
|
select json_extract('{"key1":5, "key2":[2,3]}', "$.key1", "$.key2");
|
|
select json_extract('{"key0":true, "key1":"qwe"}', "$.key1");
|
|
select json_extract(json_object('foo', 'foobar'),'$');
|
|
|
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word');
|
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3);
|
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2);
|
|
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word');
|
|
|
|
select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
|
|
|
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]');
|
|
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]');
|
|
|
|
set @j = '["a", ["b", "c"], "d"]';
|
|
select json_remove(@j, '$[0]');
|
|
select json_remove(@j, '$[1]');
|
|
select json_remove(@j, '$[2]');
|
|
set @j = '{"a": 1, "b": [2, 3]}';
|
|
select json_remove(@j, '$.b');
|
|
select json_remove(@j, '$.a');
|
|
|
|
select json_object();
|
|
select json_object("ki", 1, "mi", "ya");
|
|
create table t1 as select json_object('id', 87, 'name', 'carrot') as f;
|
|
show create table t1;
|
|
select * from t1;
|
|
drop table t1;
|
|
|
|
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2");
|
|
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[1]");
|
|
select json_exists('{"key1":"xxxx", "key2":[1, 2, 3]}', "$.key2[10]");
|
|
|
|
select json_quote('"string"');
|
|
create table t1 as select json_quote('foo');
|
|
select * from t1;
|
|
show create table t1;
|
|
drop table t1;
|
|
|
|
--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
|
|
select json_merge('string');
|
|
select json_merge('string', 123);
|
|
|
|
select json_type('{"k1":123, "k2":345}');
|
|
select json_type('[123, "k2", 345]');
|
|
select json_type("true");
|
|
select json_type('123');
|
|
select json_type('123.12');
|
|
|
|
select json_keys('{"a":{"c":1, "d":2}, "b":2}');
|
|
select json_keys('{"a":{"c":1, "d":2}, "b":2}', "$.a");
|
|
select json_keys('{"a":{"c":1, "d":2}, "b":2}', "$.b");
|
|
|
|
SET @j = '["abc", [{"k": "10"}, "def"], {"x":"abc"}, {"y":"bcd"}]';
|
|
select json_search(@j, 'one', 'abc');
|
|
select json_search(@j, 'all', 'abc');
|
|
select json_search(@j, 'all', 'abc', NULL, '$[2]');
|
|
select json_search(@j, 'all', 'abc', NULL, '$');
|
|
select json_search(@j, 'all', '10', NULL, '$');
|
|
select json_search(@j, 'all', '10', NULL, '$[*]');
|
|
select json_search(@j, 'all', '10', NULL, '$[*][0].k');
|
|
create table t1( json_col text );
|
|
insert into t1 values
|
|
('{ "a": "foobar" }'),
|
|
('{ "a": "foobar", "b": "focus", "c": [ "arm", "foot", "shoulder" ] }');
|
|
select json_search( json_col, 'all', 'foot' ) from t1;
|
|
drop table t1;
|
|
|
|
|
|
select json_unquote('"abc"');
|
|
|
|
select json_object("a", json_object("b", "abcd"));
|
|
select json_object("a", '{"b": "abcd"}');
|
|
select json_object("a", cast('{"b": "abcd"}' as json));
|
|
|
|
select cast(NULL AS JSON);
|
|
select json_depth(cast(NULL as JSON));
|
|
select json_depth('[[], {}]');
|
|
select json_depth('[[[1,2,3],"s"], {}, []]');
|
|
|