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

upsert querying an array field and $push-ing to that same field yields confusing error

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Works as Designed
    • 2.6.0
    • None
    • Write Ops
    • None
    • ALL
    • Quint 9 09/18/15

    Description

      When attempting to query on one field of an array element, the docs make it very clear that $elemMatch is not necessary.

      For example, find({"list.field":"value"}) should match the following document: { "list":[ {"field":"value"}, {"otherField":"otherValue"} ] }.

      However, doing an upsert using findAndModify on an empty collection:

       
       findAndModify(
        {"list.field":"value"},
        {"$push":{"list":{"field":"value"}}},
        {"upsert":1}
      )
      

      causes the following error:
      "list" must be an array but is of type Object in document {INVALID-MUTABLE-ELEMENT}

      Attachments

        Issue Links

          Activity

            People

              max.hirschhorn@mongodb.com Max Hirschhorn
              evan@crowdsurf.io Evan Altman
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: