mtarld / apip-ddd

An example of hexagonal API Platform 3 implementation
MIT License
321 stars 55 forks source link

Wrong count with DoctrineRepository #49

Closed Brewal closed 11 months ago

Brewal commented 11 months ago

In some cases (no paginator and queries with joins, etc.), the count method of the DoctrineRepository seems to return wrong results :

https://github.com/mtarld/apip-ddd/blob/a7608c6e1249d53821c30a434f8c15534e6a229c/src/Shared/Infrastructure/Doctrine/DoctrineRepository.php#L49-L56

I had better results relying on the doctrine paginator's logic :

if (null !== $paginator = $this->paginator()) {
    return count($paginator);
}

return (new Paginator(clone $this->queryBuilder))->count();
mtarld commented 11 months ago

This is a nice catch! Thanks, @Brewal, I've created a PR to apply your fix.