Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-3361

:continue_on_errors and safe mode fail to prevent exception from being raised both for Mongoid Models, and for Moped collections

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      I can't seem to get either Mongoid or the Moped driver to let me insert an array of documents into a collection that contains duplicates without generating exceptions.

      I'll gen up a test case in the next couple of days, but wondering if there is any obvious awareness that this is still potentially broken?

      I saw this change https://github.com/mongoid/moped/commit/f8157b43ef0e13da85dbfcb7a6dbebfa1fc8735c

      And assumed that the options is accepted.

      Here is one line of my code:

      FlightInfo.collection.insert(objects,:continue_on_error)

      This generates the standard duplicate key error

      * Moped::Errors::OperationFailure Exception: The operation
      <Moped::Protocol::Command
      @length=70
      @request_id=59
      @response_to=0
      @op_code=2004
      @flags=[]
      @full_collection_name="syd_dw.$cmd"
      @skip=0
      @limit=-1
      @selector={:getlasterror=>1, :w=>1}
      @fields=nil>
      failed with error 11000: "E11000 duplicate key error index: dw.fids.$u_index dup key: { : new Date(1352207700000), : \"QF2043\", : \"A42_1042\", : \"LANDED\" }"

      And same result when I try it this way

      session = FlightInfo.mongo_session
      session.with(safe: false) do |session|
      session[:fids].insert(objects, :continue_on_error)
      end

            Assignee:
            Unassigned Unassigned
            Reporter:
            ashrocket ashrocket
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: