Skip to content

Commit 34445ea

Browse files
authored
Merge pull request #47399 from nextcloud/fix/47275/driverException
fix: expand select and group by for calendar reminder backend
2 parents 96de697 + ab3a239 commit 34445ea

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

apps/dav/lib/CalDAV/Reminder/Backend.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public function __construct(IDBConnection $db,
4444
*/
4545
public function getRemindersToProcess():array {
4646
$query = $this->db->getQueryBuilder();
47-
$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri','cr.notification_date', 'cr.event_hash', 'cr.type'])
47+
$query->select(['cr.id', 'cr.calendar_id','cr.object_id','cr.is_recurring','cr.uid','cr.recurrence_id','cr.is_recurrence_exception','cr.event_hash','cr.alarm_hash','cr.type','cr.is_relative','cr.notification_date','cr.is_repeat_based','co.calendardata', 'c.displayname', 'c.principaluri'])
4848
->from('calendar_reminders', 'cr')
4949
->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
5050
->join('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
5151
->join('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'))
52-
->groupBy('cr.event_hash', 'cr.notification_date', 'cr.type');
52+
->groupBy('cr.event_hash', 'cr.notification_date', 'cr.type', 'cr.id', 'cr.calendar_id', 'cr.object_id', 'cr.is_recurring', 'cr.uid', 'cr.recurrence_id', 'cr.is_recurrence_exception', 'cr.alarm_hash', 'cr.is_relative', 'cr.is_repeat_based', 'co.calendardata', 'c.displayname', 'c.principaluri');
5353
$stmt = $query->execute();
5454

5555
return array_map(

apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testGetRemindersToProcess(): void {
118118
unset($rows[0]['id']);
119119
unset($rows[1]['id']);
120120

121-
$this->assertEquals($rows[0], [
121+
$expected1 = [
122122
'calendar_id' => 1,
123123
'object_id' => 1,
124124
'uid' => 'asd',
@@ -127,15 +127,15 @@ public function testGetRemindersToProcess(): void {
127127
'is_recurrence_exception' => false,
128128
'event_hash' => 'asd123',
129129
'alarm_hash' => 'asd567',
130-
'type' => 'AUDIO',
130+
'type' => 'EMAIL',
131131
'is_relative' => true,
132132
'notification_date' => 123456,
133133
'is_repeat_based' => false,
134134
'calendardata' => 'Calendar data 123',
135135
'displayname' => 'Displayname 123',
136136
'principaluri' => 'principals/users/user001',
137-
]);
138-
$this->assertEquals($rows[1], [
137+
];
138+
$expected2 = [
139139
'calendar_id' => 1,
140140
'object_id' => 1,
141141
'uid' => 'asd',
@@ -144,14 +144,16 @@ public function testGetRemindersToProcess(): void {
144144
'is_recurrence_exception' => false,
145145
'event_hash' => 'asd123',
146146
'alarm_hash' => 'asd567',
147-
'type' => 'EMAIL',
147+
'type' => 'AUDIO',
148148
'is_relative' => true,
149149
'notification_date' => 123456,
150150
'is_repeat_based' => false,
151151
'calendardata' => 'Calendar data 123',
152152
'displayname' => 'Displayname 123',
153153
'principaluri' => 'principals/users/user001',
154-
]);
154+
];
155+
156+
$this->assertEqualsCanonicalizing([$rows[0],$rows[1]], [$expected1,$expected2]);
155157
}
156158

157159
public function testGetAllScheduledRemindersForEvent(): void {

0 commit comments

Comments
 (0)