Add GROUP BY E.Id to fix mysql complaining about teh aggregate function

pull/3769/head
Isaac Connor 2023-09-20 13:35:51 -04:00
parent 2e17d2e8a4
commit 92d3e00db1
1 changed files with 8 additions and 1 deletions

View File

@ -148,9 +148,15 @@ sub Sql {
E.*,
unix_timestamp(E.StartDateTime)
AS Time,
CONCAT_WS(", ", (SELECT Name FROM Tags WHERE Id IN (SELECT TagId FROM Events_Tags WHERE EventId=E.Id)))
GROUP_CONCAT(T.Name SEPARATOR ", ")
FROM Events
AS E
LEFT JOIN Events_Tags
AS ET
ON E.Id = ET.EventId
LEFT JOIN Tags
AS T
ON T.Id = ET.TagId
';
if ( $filter_expr->{terms} ) {
@ -410,6 +416,7 @@ sub Sql {
} elsif ( $filter_expr->{sort_field} ne '' ) {
$sort_column = 'E.'.$filter_expr->{sort_field};
}
$sql .= ' GROUP BY E.Id ';
if ( $sort_column ne '' ) {
$sql .= ' ORDER BY '.$sort_column.' '.($filter_expr->{sort_asc} ? 'ASC' : 'DESC');
}