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

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.6.0
    • Fix Version/s: None
    • Component/s: Write Ops
    • Labels:
      None
    • Operating System:
      ALL
    • Sprint:
      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

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

                Dates

                Created:
                Updated:
                Resolved: