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

Upsert with $all query and $addToSet operation errors

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 2.6.3
    • None
    • Querying
    • None
    • ALL

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: