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

Splitting $pushAll and $pull conflicting operations into multiple update...

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.6
    • Affects Version/s: None
    • Component/s: None
    • None

      ...s

      When pushing or pulling values of embedded documents in different levels on a document in a single update mongoid complains with a "have conflicting mods in update" error. This change splits the conflicting operations into multiple ones, thus avoiding the error.

      For example, before this change when you had two pulls like this:

      { "addresses.0.locations" => { "_id" => { "$in" => [ "two" ]}} }   # $pull
      { "addresses" => { "_id" => { "$in" => [ "one" ]}} }               # $pull
      

      Mongoid would generate a single update, and MongoDB would complain with a "have conflicting mods in update" error.

      Also if you had a set and two conflicting pushes like this:

      { "addresses.0.street" => "Bond" }                                           # $set
      { "addresses.0.locations" => { "street" => "Bond St" } }                     # $pushAll
      { "addresses" => { "street" => "Oxford St" } }                               # $pushAll
      

      It would also generate an update with the $set and other with two $pushAll, and this second update would fail.

      The change makes any conflict like this to generate an update.

            Assignee:
            arthurnn Arthur Nogueira Neves
            Reporter:
            vicentemundim Vicente Mundim
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: