fix distinct vs group_by (#1901)

This commit is contained in:
Kevin Papst
2020-08-20 22:29:28 +02:00
committed by GitHub
parent b9ee811cbf
commit af4101c9fe
4 changed files with 29 additions and 9 deletions

View File

@@ -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;
}