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

@@ -261,7 +261,6 @@ class ActivityRepository extends EntityRepository
$qb
->select('a')
->distinct()
->from(Activity::class, 'a')
->leftJoin('a.project', 'p')
->leftJoin('p.customer', 'c')
@@ -362,6 +361,13 @@ class ActivityRepository 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('a');
// the second group by is needed to satisfy SQL standard (ONLY_FULL_GROUP_BY)
$qb->addGroupBy($orderBy);
return $qb;
}