Skip to content

Commit

Permalink
fix(search): Use corresponding table alias for recipient search
Browse files Browse the repository at this point in the history
Each recipient type has its own join and join table alias. The WHERE
clauses have to use the corresponding alias.

Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst authored and backportbot-nextcloud[bot] committed Oct 11, 2023
1 parent 903f6d9 commit c8ddbed
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/Db/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,10 +758,10 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, ?int $limit
$select->andWhere(
$qb->expr()->orX(
...array_map(function (string $email) use ($qb) {
return $qb->expr()->iLike('r0.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r1.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
}, $query->getTo()),
...array_map(function (string $label) use ($qb) {
return $qb->expr()->iLike('r0.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r1.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
}, $query->getTo()),
)
);
Expand All @@ -770,10 +770,10 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, ?int $limit
$select->andWhere(
$qb->expr()->orX(
...array_map(function (string $email) use ($qb) {
return $qb->expr()->iLike('r0.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r2.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
}, $query->getCc()),
...array_map(function (string $label) use ($qb) {
return $qb->expr()->iLike('r0.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r2.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
}, $query->getCc()),
)
);
Expand All @@ -782,10 +782,10 @@ public function findIdsByQuery(Mailbox $mailbox, SearchQuery $query, ?int $limit
$select->andWhere(
$qb->expr()->orX(
...array_map(function (string $email) use ($qb) {
return $qb->expr()->iLike('r0.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r3.email', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($email) . '%', IQueryBuilder::PARAM_STR));
}, $query->getBcc()),
...array_map(function (string $label) use ($qb) {
return $qb->expr()->iLike('r0.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
return $qb->expr()->iLike('r3.label', $qb->createNamedParameter('%' . $this->db->escapeLikeParameter($label) . '%', IQueryBuilder::PARAM_STR));
}, $query->getBcc()),
)
);
Expand Down

0 comments on commit c8ddbed

Please sign in to comment.