Only add the amountSum select for part tables if it is really required

This commit is contained in:
Jan Böhmer 2024-02-29 23:35:05 +01:00
parent c635637c00
commit a72a61091a
2 changed files with 21 additions and 10 deletions

View file

@ -135,6 +135,10 @@ class TwoStepORMAdapter extends ORMAdapter
protected function getCount(QueryBuilder $queryBuilder, $identifier): int
{
if ($this->query_modifier !== null) {
$queryBuilder = $this->query_modifier->__invoke(clone $queryBuilder);
}
//Check if the queryBuilder is having a HAVING clause, which would make the count query invalid
if (empty($queryBuilder->getDQLPart('having'))) {
//If not, we can use the simple count query