fix group by with ONLY_FULL_GROUP_BY mode (#1830)

This commit is contained in:
Kevin Papst
2020-07-18 10:16:15 +02:00
committed by GitHub
parent 7907b43ef7
commit 93a23f3fa3
4 changed files with 28 additions and 23 deletions

View File

@@ -275,29 +275,25 @@ class ActivityRepository extends EntityRepository
$where = $qb->expr()->andX();
if (\in_array($query->getVisibility(), [ActivityQuery::SHOW_VISIBLE, ActivityQuery::SHOW_HIDDEN])) {
if (!$query->isShowBoth()) {
if (!$query->isGlobalsOnly()) {
$where->add(
$qb->expr()->orX(
$qb->expr()->eq('c.visible', ':customer_visible'),
$qb->expr()->isNull('c.visible')
$qb->expr()->isNull('a.project'),
$qb->expr()->andX(
$qb->expr()->eq('c.visible', ':is_visible'),
$qb->expr()->eq('p.visible', ':is_visible')
)
)
);
$where->add(
$qb->expr()->orX(
$qb->expr()->eq('p.visible', ':project_visible'),
$qb->expr()->isNull('p.visible')
)
);
$qb->setParameter('project_visible', true, \PDO::PARAM_BOOL);
$qb->setParameter('customer_visible', true, \PDO::PARAM_BOOL);
$qb->setParameter('is_visible', true, \PDO::PARAM_BOOL);
}
$where->add('a.visible = :visible');
$where->add($qb->expr()->eq('a.visible', ':visible'));
if (ActivityQuery::SHOW_VISIBLE === $query->getVisibility()) {
if ($query->isShowVisible()) {
$qb->setParameter('visible', true, \PDO::PARAM_BOOL);
} elseif (ActivityQuery::SHOW_HIDDEN === $query->getVisibility()) {
} elseif ($query->isShowHidden()) {
$qb->setParameter('visible', false, \PDO::PARAM_BOOL);
}
}
@@ -359,8 +355,10 @@ 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 / pagination results
// $qb->addGroupBy('a.id');
// the second group by is needed due to SQL standard (even though logically not really required for this query)
$qb->addGroupBy('a.id')->addGroupBy($orderBy);
// $qb->addGroupBy($orderBy);
return $qb;
}