KnpLabs / KnpLabs/KnpPaginatorBundle
Count with Group by fails
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 332
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 3
Description
I have the following query:
```
$qb = $em->createQueryBuilder();
$qb->select('de', 'COUNT(de.auftragsnummer) as menge');
$qb->from('App\Entity\DispositionsplanEintrag', 'de');
$qb->where('de.geloescht IS NULL');
$qb->groupBy('de.auftragsnummer');
$qb->orderBy('de.auftragsnummer', 'ASC');
```
Executed by the following code:
```
$query = $qb->getQuery();
$paginator = $this->get('knp_paginator');
$eintraege = $paginator->paginate($query, $request->query->getInt('page', 1), 20);
```
it results in having the variable "menge" always has the value 1.
if I execute `$eintraege = $query->getResult();` then the value of "menge" is correct.
Is there anything wrong in my example, or is it a bug?
Thank you!
Contributor guide
Research direction
Start with the paginator->paginate($query, ...) path and compare it with the same query's getResult() output. Reproduce the grouped COUNT query from the report, inspect how pagination handles the count and selected fields, and consider the issue done when paginated results preserve the correct menge values for each group.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, symfony
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100