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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      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:
            emily.stolfo Emily Stolfo
            Reporter:
            vicentemundim Vicente Mundim
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: