Chad Dombrova  committed 1d83fb3

Fix an issue with MongoBackend where newly inserted documents were using unique
ObjectIds for _id instead of the model's primary key. Since each new document
inserted did not have an _id that matched the model's primary key, and instead had
a unique _id, the upserts failed to update the existing document and instead wrote a brand
new document each time. Eventually, a doc would be inserted with the desired _id
(though I'm still unclear on how) and the out-of-control replication would then
be halted.

  • Participants
  • Parent commits 8de1073
  • Branches orms

Comments (0)

Files changed (1)

File denormalize/backend/

         log.debug('added: %s %s',, doc_id)
         col = getattr(self.db,
         # Replace any existing document
+        doc['_id'] = doc_id
         col.update({'_id': doc_id}, doc, upsert=True)
+        del doc['_id']
     def changed(self, collection, doc_id, doc):
         log.debug('changed: %s %s',, doc_id)