Skip to content

Commit

Permalink
fixup! fix #4479 by ensuring subquery in findNewIds never returns NULL
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst committed Sep 13, 2023
1 parent ed2d0da commit e8b34b0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/Integration/Db/MessageMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
use ChristophWurst\Nextcloud\Testing\TestCase;
use OCA\Mail\Account;
use OCA\Mail\Db\Mailbox;
use OCA\Mail\Db\MessageMapper;
use OCA\Mail\Db\TagMapper;
use OCA\Mail\Support\PerformanceLogger;
Expand Down Expand Up @@ -140,4 +141,28 @@ public function testResetPreviewDataFlag(): void {
$result->closeCursor();
self::assertEquals(0, $cnt);
}

/**
* Verify we still find the one message of the mailbox if the passed IDs do not exist
*/
public function testFindNewIdsCoalesence(): void {
$uid = time();
$mailbox = new Mailbox();
$mailbox->setId(1);
$qb = $this->db->getQueryBuilder();
$insert = $qb->insert($this->mapper->getTableName())
->values([
'uid' => $qb->createNamedParameter($uid, IQueryBuilder::PARAM_INT),
'message_id' => $qb->createNamedParameter('<abc@123.com>'),
'mailbox_id' => $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT),
'subject' => $qb->createNamedParameter('TEST'),
'sent_at' => $qb->createNamedParameter(time(), IQueryBuilder::PARAM_INT),
]);
$insert->executeStatement();
$id = $insert->getLastInsertId();

$found = $this->mapper->findNewIds($mailbox, [$id + 1]);

self::assertCount(1, $found);
}
}

0 comments on commit e8b34b0

Please sign in to comment.