-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.10.3, 2.11.2
-
Component/s: None
-
None
-
Fully Compatible
Upon upgrading to v2.11.2 of the `mongo` gem, our software's uses of `upsert: true` failed to insert new documents. Example:
collection.find.count # => 0 collection.find(_id: BSON::ObjectId('5dfa8ad7ea64ae457941102b')).update_one({'$set' => {foo: 'bar'}}, upsert: true) # => #<Mongo::Operation::Update::Legacy::Result:0x70339487480360 documents=[]> collection.find.count # => 0
What we expect to happen is for a new document with keys _id and foo to be inserted.
What actually happens is no document is inserted.
Downgrading to v2.9.x fixes this problem. It appears related to a mismatch of symbol vs. string "upsert" keys in https://github.com/mongodb/mongo-ruby-driver/pull/1439 (https://jira.mongodb.org/browse/RUBY-1878).