Skip to content

Commit

Permalink
Merge pull request #6391 from nextcloud/backport/only-full-group-by-s…
Browse files Browse the repository at this point in the history
…ql-error/stable28

[stable28] Avoid sql error on ONLY_FULL_GROUP_BY
  • Loading branch information
juliusknorr authored Oct 14, 2024
2 parents 46a83d8 + 4608fe5 commit 9a280b3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/Db/CardMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function queryCardsByBoard(int $boardId): IQueryBuilder {

public function queryCardsByBoards(array $boardIds): IQueryBuilder {
$qb = $this->db->getQueryBuilder();
$qb->select('c.*')
$qb->selectDistinct('c.*')
->from('deck_cards', 'c')
->innerJoin('c', 'deck_stacks', 's', $qb->expr()->eq('s.id', 'c.stack_id'))
->andWhere($qb->expr()->in('s.board_id', $qb->createNamedParameter($boardIds, IQueryBuilder::PARAM_INT_ARRAY)));
Expand Down Expand Up @@ -339,7 +339,6 @@ public function search(array $boardIds, SearchQuery $query, int $limit = null, i
);
}

$qb->groupBy('c.id');
$qb->orderBy('c.last_modified', 'DESC');
if ($limit !== null) {
$qb->setMaxResults($limit);
Expand Down Expand Up @@ -383,7 +382,6 @@ public function searchComments(array $boardIds, SearchQuery $query, int $limit =
$tokenMatching
);

$qb->groupBy('comments.id', 'c.id');
$qb->orderBy('comments.id', 'DESC');
if ($limit !== null) {
$qb->setMaxResults($limit);
Expand Down

0 comments on commit 9a280b3

Please sign in to comment.