Skip to content

Commit

Permalink
fix migration selecting column which is not in the groupby, solution:…
Browse files Browse the repository at this point in the history
… aggregate function MAX

Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
  • Loading branch information
julien-nc committed Oct 24, 2024
1 parent d24c043 commit 82a44a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Migration/Version070002Date20241020160425.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
);

$qbSelect = $this->connection->getQueryBuilder();
$qbSelect->select('id', 'user', 'path', $qbSelect->createFunction('COUNT(*)'))
$qbSelect->select('user', 'path', $qbSelect->createFunction('COUNT(*)'), $qbSelect->createFunction('MAX(id)'))
->from('gpxpod_directories')
->having('COUNT(*) > 1')
->groupBy('user', 'path');
Expand All @@ -41,7 +41,7 @@ public function preSchemaChange(IOutput $output, Closure $schemaClosure, array $
$selectResult = $qbSelect->executeQuery();
while ($row = $selectResult->fetch()) {
$hasDuplicates = true;
$id = $row['id'];
$id = $row['MAX(id)'];
$qbDelete->setParameter('idToDelete', $id, IQueryBuilder::PARAM_INT);
$qbDelete->executeStatement();
}
Expand Down

0 comments on commit 82a44a0

Please # to comment.