mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the
square brackets are not included. Item_func_json_arrayagg::copy_or_same() should be implemented.
This commit is contained in:
@ -1366,5 +1366,21 @@ JSON_OBJECTAGG(a, e)
|
||||
DROP VIEW v;
|
||||
DROP TABLE t1;
|
||||
#
|
||||
# MDEV-23004 When using GROUP BY with JSON_ARRAYAGG with joint table, the square brackets are not included.
|
||||
#
|
||||
CREATE TABLE t1(id int primary key, name varchar(50));
|
||||
CREATE TABLE t2(id int, owner_id int);
|
||||
INSERT INTO t1 VALUES (1, "name1"), (2, "name2"), (3, "name3");
|
||||
INSERT INTO t2 VALUES (1, 1), (2, 1), (3, 2), (4, 3);
|
||||
SELECT t1.id, JSON_ARRAYAGG(JSON_OBJECT('id',t2.id)) as materials
|
||||
from t1 LEFT JOIN t2 on t1.id = t2.owner_id
|
||||
GROUP BY t1.id ORDER BY id;
|
||||
id materials
|
||||
1 ["{\"id\": 1}","{\"id\": 2}"]
|
||||
2 ["{\"id\": 3}"]
|
||||
3 ["{\"id\": 4}"]
|
||||
DROP TABLE t1;
|
||||
DROP TABLE t2;
|
||||
#
|
||||
# End of 10.5 tests
|
||||
#
|
||||
|
Reference in New Issue
Block a user