diff options
author | Joas Schilling <coding@schilljs.com> | 2022-03-21 13:01:00 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-03-21 13:08:52 +0300 |
commit | 9d5cfbdd8dc8b0f27fb2357c9be62a6dd692f23b (patch) | |
tree | 069d38b2171df4062aa9c60eff4d004357ddce95 /lib/Service | |
parent | 3af97fc68ea8865b09e40b9158876fe8791e2f0a (diff) |
Group on PHP level as MariaDB can not handle this correctly:
MySQL docs:
Reject queries for which the select list, HAVING condition, or ORDER BY
list refer to nonaggregated columns that are neither named in the GROUP BY
clause nor are functionally dependent on (uniquely determined by) GROUP BY columns.
MariaDB docs:
For SELECT ... GROUP BY queries, disallow SELECTing columns which are
not referred to in the GROUP BY clause, unless they are passed to an
aggregate function like COUNT() or MAX(). Produce a 1055 error.
Ref https://jira.mariadb.org/browse/MDEV-11588
Similarly Oracle seems to fail with the query before
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Service')
-rw-r--r-- | lib/Service/ParticipantService.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Service/ParticipantService.php b/lib/Service/ParticipantService.php index 044054bf2..a2998890a 100644 --- a/lib/Service/ParticipantService.php +++ b/lib/Service/ParticipantService.php @@ -1226,7 +1226,7 @@ class ParticipantService { $helper = new SelectHelper(); $helper->selectAttendeesTable($query); - $helper->selectSessionsTableMax($query); + $helper->selectSessionsTable($query); $query->from('talk_attendees', 'a') // Currently we only care if the user has a session at all, so we can select any: #ThisIsFine ->leftJoin( @@ -1234,10 +1234,16 @@ class ParticipantService { $query->expr()->eq('s.attendee_id', 'a.id') ) ->where($query->expr()->eq('a.room_id', $query->createNamedParameter($room->getId(), IQueryBuilder::PARAM_INT))) - ->andWhere($query->expr()->eq('a.notification_level', $query->createNamedParameter($notificationLevel, IQueryBuilder::PARAM_INT))) - ->groupBy('a.id'); + ->andWhere($query->expr()->eq('a.notification_level', $query->createNamedParameter($notificationLevel, IQueryBuilder::PARAM_INT))); - return $this->getParticipantsFromQuery($query, $room); + $participants = $this->getParticipantsFromQuery($query, $room); + + $uniqueAttendees = []; + foreach ($participants as $participant) { + $uniqueAttendees[$participant->getAttendee()->getId()] = $participant; + } + + return array_values($uniqueAttendees); } /** |