Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-14391

Upsert with $all query and $addToSet operation errors

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.3
    • Component/s: Querying
    • None
    • ALL

      With an empty collection, run this:

      db.Food.update(
          { "names" : { "$all" : [ "corn"]}},
          { "$addToSet" : { "names" : "corn"}},
          { upsert: true });
      

      Results in this error:
      Cannot apply $addToSet to a non-array field. Field named 'names' has a non-array type String in the document INVALID-MUTABLE-ELEMENT

      Tested in 2.6.3
      It worked fine in 2.4.10

            Assignee:
            Unassigned Unassigned
            Reporter:
            myoffe Michael Yoffe
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: