Fixed error when using postgres in a SELECT count query where a ORDER BY was added by mistake

This commit is contained in:
Alejandro Celaya 2019-03-05 13:50:44 +01:00
parent 425f254453
commit 0f81c3ab92

View file

@ -50,7 +50,8 @@ DQL;
?int $offset = null ?int $offset = null
): array { ): array {
$qb = $this->createVisitsByShortCodeQueryBuilder($shortCode, $dateRange); $qb = $this->createVisitsByShortCodeQueryBuilder($shortCode, $dateRange);
$qb->select('v'); $qb->select('v')
->orderBy('v.date', 'DESC');
if ($limit !== null) { if ($limit !== null) {
$qb->setMaxResults($limit); $qb->setMaxResults($limit);
@ -76,8 +77,7 @@ DQL;
$qb->from(Visit::class, 'v') $qb->from(Visit::class, 'v')
->join('v.shortUrl', 'su') ->join('v.shortUrl', 'su')
->where($qb->expr()->eq('su.shortCode', ':shortCode')) ->where($qb->expr()->eq('su.shortCode', ':shortCode'))
->setParameter('shortCode', $shortCode) ->setParameter('shortCode', $shortCode);
->orderBy('v.date', 'DESC') ;
// Apply date range filtering // Apply date range filtering
if ($dateRange !== null && $dateRange->getStartDate() !== null) { if ($dateRange !== null && $dateRange->getStartDate() !== null) {