Upsert with $-positional operator can create bad documents

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 2.3.2
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      From a recent question in training: "what happens if you try to use the positional operator with upsert?". It appears it can create an invalid document with a dollarsign in the field name:

      db.foo.update(

      { 'x.a' : 6 }

      , { $set :

      { 'x.$.b' : -5 }

      }, true )
      db.foo.find().pretty()
      {
      "_id" : ObjectId("4f1724449afa61972cf8ef0b"),
      "x" : {
      "$" :

      { "b" : -5 }

      ,
      "a" : 6
      }
      }

            Assignee:
            Unassigned
            Reporter:
            Richard Kreuter (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: