fix distinct vs group_by (#1901)
This commit is contained in:
@@ -137,7 +137,6 @@ class InvoiceRepository extends EntityRepository
|
||||
|
||||
$qb
|
||||
->select('i')
|
||||
->distinct()
|
||||
->from(Invoice::class, 'i')
|
||||
;
|
||||
|
||||
@@ -152,6 +151,13 @@ class InvoiceRepository extends EntityRepository
|
||||
|
||||
$this->addPermissionCriteria($qb, $query->getCurrentUser());
|
||||
|
||||
// this will make sure, that we do not accidentally create results with multiple rows,
|
||||
// which would result in a wrong LIMIT with paginated results
|
||||
$qb->addGroupBy('i');
|
||||
|
||||
// the second group by is needed to satisfy SQL standard (ONLY_FULL_GROUP_BY)
|
||||
$qb->addGroupBy($orderBy);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user