fix distinct vs group_by (#1901)
This commit is contained in:
@@ -255,7 +255,6 @@ class ProjectRepository extends EntityRepository
|
||||
|
||||
$qb
|
||||
->select('p')
|
||||
->distinct()
|
||||
->from(Project::class, 'p')
|
||||
->leftJoin('p.customer', 'c')
|
||||
;
|
||||
@@ -367,6 +366,13 @@ class ProjectRepository extends EntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
// 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('p');
|
||||
|
||||
// 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