Skip to content

Commit

Permalink
[BUGFIX] Fix for sql_mode=only_full_group_by
Browse files Browse the repository at this point in the history
In newer MySQL versions the query in GlossaryRepository::findAllForIndex()
will fail if sql_mode contains only_full_group_by.

The problem is the ORDER BY clause which does not match the GROUP BY.

Resolves: #10
  • Loading branch information
sypets committed Jan 14, 2020
1 parent 1c820e6 commit 5feeea6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Classes/Domain/Repository/GlossaryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class GlossaryRepository extends Repository
*/
public function findAllForIndex()
{
$previousOrderings = $this->defaultOrderings;
$this->defaultOrderings = [];
/** @var Query $query */
$query = $this->createQuery();
// Get the query parser via object manager to use dependency injection
Expand All @@ -30,8 +32,9 @@ public function findAllForIndex()
// Add our select and group by
$queryBuilder->selectLiteral('substr(' . $queryBuilder->quoteIdentifier('short') . ', 1, 1) AS ' . $queryBuilder->quoteIdentifier('char'))
->groupBy('char');

return $query->statement($queryBuilder)->execute(true);
$result = $query->statement($queryBuilder)->execute(true);
$this->defaultOrderings = $previousOrderings;
return $result;
}

/**
Expand Down

0 comments on commit 5feeea6

Please sign in to comment.