diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index ee312aac6cb..d40107772cc 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1235,6 +1235,11 @@ JSON_ARRAYAGG(NULL) SELECT JSON_ARRAYAGG("null") FROM (SELECT 1 AS t) AS A; JSON_ARRAYAGG("null") ["null"] +create view v as (select json_arrayagg(json_object("type", "permPeriod", "id", "asd")) as JSON_DATA); +select * from v; +JSON_DATA +[{"type": "permPeriod", "id": "asd"}] +drop view v; # # End of 10.5 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 95d35d22d1e..40e69a61850 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -755,6 +755,10 @@ select json_objectagg(a, b) over () from (select 1 a, 2 b) t; SELECT JSON_ARRAYAGG(NULL) FROM (SELECT 1 AS t) AS A; SELECT JSON_ARRAYAGG("null") FROM (SELECT 1 AS t) AS A; +create view v as (select json_arrayagg(json_object("type", "permPeriod", "id", "asd")) as JSON_DATA); +select * from v; +drop view v; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 0ce5352ccfb..510cf096575 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -4305,7 +4305,7 @@ String* Item_func_group_concat::val_str(String* str) void Item_func_group_concat::print(String *str, enum_query_type query_type) { - str->append(STRING_WITH_LEN("group_concat(")); + str->append(func_name()); if (distinct) str->append(STRING_WITH_LEN("distinct ")); for (uint i= 0; i < arg_count_field; i++) @@ -4328,9 +4328,13 @@ void Item_func_group_concat::print(String *str, enum_query_type query_type) str->append(STRING_WITH_LEN(" DESC")); } } - str->append(STRING_WITH_LEN(" separator \'")); - str->append_for_single_quote(separator->ptr(), separator->length()); - str->append(STRING_WITH_LEN("\'")); + + if (sum_func() == GROUP_CONCAT_FUNC) + { + str->append(STRING_WITH_LEN(" separator \'")); + str->append_for_single_quote(separator->ptr(), separator->length()); + str->append(STRING_WITH_LEN("\'")); + } if (limit_clause) {