Skip to content

Commit 2906dda

Browse files
committed
Revert "Fix Mongo adapter ignore mode: pass ignoreDuplicates to client and fix _uid mapping"
This reverts commit 93a9136.
1 parent 93a9136 commit 2906dda

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

src/Database/Adapter/Mongo.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,37 +1576,18 @@ public function createDocuments(Document $collection, array $documents, bool $ig
15761576
}
15771577
}
15781578

1579-
if ($ignore) {
1580-
$options['ignoreDuplicates'] = true;
1581-
}
1582-
15831579
try {
1584-
$inserted = $this->client->insertMany($name, $records, $options);
1580+
$documents = $this->client->insertMany($name, $records, $options);
15851581
} catch (MongoException $e) {
15861582
throw $this->processException($e);
15871583
}
15881584

1589-
$insertedUids = [];
1590-
foreach ($inserted as $record) {
1591-
$arr = $this->client->toArray($record);
1592-
// _uid is excluded from replaceChars transformation, so extract it before conversion
1593-
$uid = $arr['_uid'] ?? '';
1594-
$arr = $this->replaceChars('_', '$', $arr);
1595-
$insertedUids[$uid] = new Document($arr);
1596-
}
1597-
1598-
if ($ignore) {
1599-
$result = [];
1600-
foreach ($records as $i => $record) {
1601-
$uid = $record['_uid'] ?? '';
1602-
if (isset($insertedUids[$uid])) {
1603-
$result[] = $documents[$i];
1604-
}
1605-
}
1606-
return $result;
1585+
foreach ($documents as $index => $document) {
1586+
$documents[$index] = $this->replaceChars('_', '$', $this->client->toArray($document));
1587+
$documents[$index] = new Document($documents[$index]);
16071588
}
16081589

1609-
return \array_values($insertedUids);
1590+
return $documents;
16101591
}
16111592

16121593
/**

0 commit comments

Comments
 (0)