The return value when bulk writing data with :continue_on_error => true does not behave as expected.
coll.insert({:_id => 'AAAAA'}) p coll.find.to_a => [{"_id"=>"AAAAA", "param"=>1}] p coll.insert([{:_id => 'AAAAA'}, {:_id => 'AAAAB'}], :continue_on_error => true) => ["AAAAA", "AAAAB"] p coll.find.to_a => [{"_id"=>"AAAAA", "param"=>1}, {"_id"=>"AAAAB"}]
The documentation specifies that the return value from insert is "The _id of the inserted document or a list of _ids of all inserted documents."
In this case AAAAA was not written during the bulk insert and should not be returned as an "inserted document".
The documentation makes it sound like the return value can be used as a replacement for a duplication check, which is not the case with this behavior.
- depends on
-
SERVER-4637 E11000 (duplicate key error) should return a list of duplicate keys and _ids in insert, bulk insert, and continue_on_error inserts.
- Open