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

Upsert with $-positional operator can create bad documents

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

      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 Unassigned
            Reporter:
            richard.kreuter Richard Kreuter (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: