From a64982f96c2db3a113784f255bad6b335d240415 Mon Sep 17 00:00:00 2001 From: Michal Nicpon <39177923+michalnicp@users.noreply.github.com> Date: Mon, 25 Apr 2022 14:43:08 -0600 Subject: [PATCH] Remove use of JSON_ARRAYAGG (#5350) Not supported in MySQL < 5.7.22 --- changes/issue-5319-json-arrayagg | 2 ++ server/datastore/mysql/hosts.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 changes/issue-5319-json-arrayagg diff --git a/changes/issue-5319-json-arrayagg b/changes/issue-5319-json-arrayagg new file mode 100644 index 0000000000..eec36a0670 --- /dev/null +++ b/changes/issue-5319-json-arrayagg @@ -0,0 +1,2 @@ +* Remove usage of JSON_ARRAYAGG in sql queries. Not supported in MySQL < 5.7.22 and + AWS RDS Aurora used in Terraform. diff --git a/server/datastore/mysql/hosts.go b/server/datastore/mysql/hosts.go index bde61e5000..8a00060907 100644 --- a/server/datastore/mysql/hosts.go +++ b/server/datastore/mysql/hosts.go @@ -1672,13 +1672,13 @@ SELECT team_id id, 'os_versions' type, COALESCE( - JSON_ARRAYAGG( + CONCAT('[', GROUP_CONCAT( JSON_OBJECT( 'hosts_count', hosts_count, 'name', name, 'platform', platform ) - ), + ), ']'), JSON_ARRAY() ) json_value FROM