Skip to content

Commit 9653052

Browse files
committed
Add tenant filter to Mongo adapter pre-filter query in ignore mode
1 parent 37aace4 commit 9653052

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Database/Adapter/Mongo.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,11 @@ public function createDocuments(Document $collection, array $documents, bool $ig
14931493
$uids = \array_filter(\array_map(fn ($r) => $r['_uid'] ?? null, $records));
14941494
if (!empty($uids)) {
14951495
$findOptions = $this->getTransactionOptions(['projection' => ['_uid' => 1]]);
1496-
$result = $this->client->find($name, ['_uid' => ['$in' => \array_values($uids)]], $findOptions);
1496+
$filters = ['_uid' => ['$in' => \array_values($uids)]];
1497+
if ($this->sharedTables) {
1498+
$filters['_tenant'] = $this->getTenantFilters($collection->getId());
1499+
}
1500+
$result = $this->client->find($name, $filters, $findOptions);
14971501
$existingUids = [];
14981502
foreach ($result->cursor->firstBatch ?? [] as $doc) {
14991503
$existingUids[$doc->_uid] = true;

0 commit comments

Comments
 (0)