|
Possible cases (from version 10.5):
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),JSON_OBJECT(_LATIN1 'number', _LATIN1'two')));
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),JSON_OBJECT(_LATIN1 'number', _LATIN1'two')))
|
{"number": "one"}:{"number": "two"}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),JSON_OBJECT('number', 'two')));
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),JSON_OBJECT('number', 'two')))
|
{"number": "one"}:{"number": "two"}
|
SELECT JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),JSON_OBJECT(_LATIN1 'number', _LATIN1'two'));
|
JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),JSON_OBJECT(_LATIN1 'number', _LATIN1'two'))
|
{"number": ["one", "two"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT('number', 'one'),JSON_OBJECT('number', 'two'));
|
JSON_MERGE(JSON_OBJECT('number', 'one'),JSON_OBJECT('number', 'two'))
|
{"number": ["one", "two"]}
|
SELECT JSON_ARRAYAGG(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'));
|
JSON_ARRAYAGG(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket'))
|
[{"plugin": "unix_socket"}]
|
|
SELECT JSON_ARRAYAGG(JSON_OBJECT('plugin', 'unix_socket'));
|
JSON_ARRAYAGG(JSON_OBJECT('plugin', 'unix_socket'))
|
[{"plugin": "unix_socket"}]
|
CREATE TABLE t1 (a varchar(10), b varchar(10));
|
INSERT INTO t1 VALUES ("number","one"), ("number","two"), (_LATIN1'number',_LATIN1'three'),(_LATIN1'number',"four");
|
|
CREATE VIEW v1 AS SELECT * FROM t1;
|
|
SELECT JSON_OBJECTAGG(a,b) FROM t1;
|
JSON_OBJECTAGG(a,b)
|
{"number":"one", "number":"two", "number":"three", "number":"four"}
|
|
SELECT JSON_OBJECTAGG(a,b) FROM v1;
|
JSON_OBJECTAGG(a,b)
|
{"number":"one", "number":"two", "number":"three", "number":"four"}
|
|
SELECT JSON_OBJECTAGG(v1.a,t1.b) FROM v1,t1;
|
JSON_OBJECTAGG(v1.a,t1.b)
|
{"number":"one", "number":"one", "number":"one", "number":"one", "number":"two", "number":"two", "number":"two", "number":"two", "number":"three", "number":"three", "number":"three", "number":"three", "number":"four", "number":"four", "number":"four", "number":"four"}
|
|
SELECT JSON_ARRAYAGG(b) from t1;
|
JSON_ARRAYAGG(b)
|
["one","two","three","four"]
|
|
SELECT JSON_ARRAYAGG(b) from v1;
|
JSON_ARRAYAGG(b)
|
["one","two","three","four"]
|
|
SELECT JSON_OBJECT(a, b) from t1;
|
JSON_OBJECT(a, b)
|
{"number": "one"}
|
{"number": "two"}
|
{"number": "three"}
|
{"number": "four"}
|
|
SELECT JSON_OBJECT(a, b) from v1;
|
JSON_OBJECT(a, b)
|
{"number": "one"}
|
{"number": "two"}
|
{"number": "three"}
|
{"number": "four"}
|
|
SELECT JSON_OBJECT(v1.a, t1.b) from v1,t1;
|
JSON_OBJECT(v1.a, t1.b)
|
{"number": "one"}
|
{"number": "one"}
|
{"number": "one"}
|
{"number": "one"}
|
{"number": "two"}
|
{"number": "two"}
|
{"number": "two"}
|
{"number": "two"}
|
{"number": "three"}
|
{"number": "three"}
|
{"number": "three"}
|
{"number": "three"}
|
{"number": "four"}
|
{"number": "four"}
|
{"number": "four"}
|
{"number": "four"}
|
|
SELECT JSON_ARRAYAGG(JSON_OBJECT(a, b)) from t1;
|
JSON_ARRAYAGG(JSON_OBJECT(a, b))
|
[{"number": "one"},{"number": "two"},{"number": "three"},{"number": "four"}]
|
|
SELECT JSON_ARRAYAGG(JSON_OBJECT(a, b)) from v1;
|
JSON_ARRAYAGG(JSON_OBJECT(a, b))
|
[{"number": "one"},{"number": "two"},{"number": "three"},{"number": "four"}]
|
|
SELECT JSON_ARRAYAGG(JSON_OBJECT(v1.a, t1.b)) from v1,t1;
|
JSON_ARRAYAGG(JSON_OBJECT(v1.a, t1.b))
|
[{"number": "one"},{"number": "one"},{"number": "one"},{"number": "one"},{"number": "two"},{"number": "two"},{"number": "two"},{"number": "two"},{"number": "three"},{"number": "three"},{"number": "three"},{"number": "three"},{"number": "four"},{"number": "four"},{"number": "four"},{"number": "four"}]
|
|
DROP VIEW v1;
|
DROP TABLE t1;
|
CREATE TABLE t1 (a json, b json);
|
INSERT INTO t1 VALUES ('{"number":"one"}','{"number":"two"}'), ('{"number":"one"}','{"number":"two"}');
|
|
CREATE VIEW v1 AS SELECT * FROM t1;
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",a,b) ORDER BY a DESC LIMIT 1) FROM t1;
|
GROUP_CONCAT(CONCAT_WS(":",a,b) ORDER BY a DESC LIMIT 1)
|
{"number":"one"}:{"number":"two"}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",a,b) ORDER BY a DESC LIMIT 1) FROM v1;
|
GROUP_CONCAT(CONCAT_WS(":",a,b) ORDER BY a DESC LIMIT 1)
|
{"number":"one"}:{"number":"two"}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",v1.a,t1.b) ORDER BY v1.a DESC LIMIT 1) FROM v1,t1;
|
GROUP_CONCAT(CONCAT_WS(":",v1.a,t1.b) ORDER BY v1.a DESC LIMIT 1)
|
{"number":"one"}:{"number":"two"}
|
|
SELECT JSON_ARRAYAGG(a) from t1;
|
JSON_ARRAYAGG(a)
|
[{"number":"one"},{"number":"one"}]
|
|
SELECT JSON_ARRAYAGG(a) from v1;
|
JSON_ARRAYAGG(a)
|
[{"number":"one"},{"number":"one"}]
|
|
SELECT JSON_MERGE(a , b) from t1;
|
JSON_MERGE(a , b)
|
{"number": ["one", "two"]}
|
{"number": ["one", "two"]}
|
|
SELECT JSON_MERGE(a , b) from v1;
|
JSON_MERGE(a , b)
|
{"number": ["one", "two"]}
|
{"number": ["one", "two"]}
|
|
SELECT JSON_MERGE(v1.a , t1.b) from v1,t1;
|
JSON_MERGE(v1.a , t1.b)
|
{"number": ["one", "two"]}
|
{"number": ["one", "two"]}
|
{"number": ["one", "two"]}
|
{"number": ["one", "two"]}
|
|
DROP VIEW v1;
|
DROP TABLE t1;
|
|
|
Cases with view created from json object:
CREATE VIEW v1 AS SELECT JSON_OBJECT(_LATIN1 'plugin', _LATIN1'unix_socket') as v1_json;
|
|
SELECT v1_json FROM v1;
|
v1_json
|
{"plugin": "unix_socket"}
|
SELECT JSON_MERGE(v1_json,v1_json) FROM v1;
|
JSON_MERGE(v1_json,v1_json)
|
{"plugin": ["unix_socket", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'two'),JSON_OBJECT('number', 'one'),v1_json,v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'two'),JSON_OBJECT('number', 'one'),v1_json,v1_json)
|
{"number": ["two", "one"], "plugin": ["unix_socket", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT('plugin', 'one'),v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT('plugin', 'one'),v1_json)
|
{"plugin": ["one", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'two'),v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'two'),v1_json)
|
{"plugin": ["two", "unix_socket"]}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),v1_json)) FROM v1;
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),v1_json))
|
{"number": "one"}:{"plugin": "unix_socket"}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),v1_json)) FROM v1;
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),v1_json))
|
{"number": "one"}:{"plugin": "unix_socket"}
|
|
DROP VIEW v1;
|
CREATE VIEW v1 AS SELECT JSON_OBJECT('plugin','unix_socket') as v1_json;
|
|
SELECT v1_json FROM v1;
|
v1_json
|
{"plugin": "unix_socket"}
|
|
SELECT JSON_MERGE(v1_json,v1_json) FROM v1;
|
JSON_MERGE(v1_json,v1_json)
|
{"plugin": ["unix_socket", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'two'),JSON_OBJECT('number', 'one'),v1_json,v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT(_LATIN1 'number', _LATIN1'two'),JSON_OBJECT('number', 'one'),v1_json,v1_json)
|
{"number": ["two", "one"], "plugin": ["unix_socket", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT('plugin', 'one'),v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT('plugin', 'one'),v1_json)
|
{"plugin": ["one", "unix_socket"]}
|
|
SELECT JSON_MERGE(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'two'),v1_json) FROM v1;
|
JSON_MERGE(JSON_OBJECT(_LATIN1 'plugin', _LATIN1'two'),v1_json)
|
{"plugin": ["two", "unix_socket"]}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),v1_json)) FROM v1;
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT(_LATIN1 'number', _LATIN1'one'),v1_json))
|
{"number": "one"}:{"plugin": "unix_socket"}
|
|
SELECT GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),v1_json)) FROM v1;
|
GROUP_CONCAT(CONCAT_WS(":",JSON_OBJECT('number', 'one'),v1_json))
|
{"number": "one"}:{"plugin": "unix_socket"}
|
|
DROP VIEW v1;
|
|