[MDEV-13702] JSON grouping Created: 2017-09-01  Updated: 2017-09-04

Status: Open
Project: MariaDB Server
Component/s: JSON
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Andrej Thomsen Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Grouping functions can't be used within "JSON_ARRAY()". So if I want to create an array with an unknown number of elements, the only way I found out so far was the following. Also the same applies for "JSON_MERGE()" but the use cases for that are very limited.

SELECT
                JSON_OBJECT(
                    'Staff', JSON_OBJECT(
                        'Staff_ID', Staff_ID,
                        'StaffNumber', Staff_Number,
                        'StaffName', Staff_Name
                    ),
                    'Permissions', CONCAT(
                        '[',
                        GROUP_CONCAT(
                            JSON_OBJECT(Permission_ID, Permission_Flag)
                        ),
                        ']'
                    )
                ) AS StaffObj
FROM            Staff
NATURAL JOIN    Company
NATURAL JOIN    Staff_Permissions
GROUP BY        Staff_ID;



 Comments   
Comment by Sergei Golubchik [ 2017-09-04 ]

One solution to this will be implemented in MDEV-7773.

Generated at Thu Feb 08 08:07:42 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.