Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-356

Bulk insert with :continue_on_error returns ids that were not written to collection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 12_01_17
    • Affects Version/s: 1.4.1
    • Component/s: None
    • Labels:
    • Environment:
      MongoDB 2.0.1

      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.

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            effata David Tollmyr
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: