Bug #79812 | JSON_ARRAY and JSON_OBJECT return inproper JSON when used with GROUP_CONCAT | ||
---|---|---|---|
Submitted: | 30 Dec 2015 18:22 | Modified: | 10 Feb 2016 13:55 |
Reporter: | Bear Limvere | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: JSON | Severity: | S2 (Serious) |
Version: | 5.7.10, 8.0.0 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[30 Dec 2015 18:22]
Bear Limvere
[2 Jan 2016 5:14]
MySQL Verification Team
Hello Bear Limvere, Thank you for the report and test case. Verified as described. Thanks, Umesh
[10 Feb 2016 13:55]
Knut Anders Hatlen
This is actually intentional behaviour, even though it might look a bit confusing. GROUP_CONCAT returns a string. JSON_ARRAY does not parse string arguments as JSON text, but instead converts them to JSON string scalars. Because of this, JSON_ARRAY(GROUP_CONCAT(...)) returns a JSON array with one element, which is a string. There is another request for adding JSON aggregate functions, which would provide the functionality you need. See bug#79010. For now, it should be possible to work around this lacking functionality with manual creation and parsing of JSON text. Something like this should do the trick: CAST(CONCAT('[', GROUP_CONCAT( JSON_OBJECT( 'user_id', user.user_id, 'user_name', user.user_name, 'is_active', user.is_active)), ']') AS JSON)
[18 Jun 2016 21:35]
Omer Barnir
Posted by developer: Reported version value updated to reflect release name change from 5.8 to 8.0