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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Done
    • 1.4.1
    • 12_01_17
    • None
    • MongoDB 2.0.1

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: