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

Reject upsert if would create duplicate field names

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.5.4
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • ALL

      > db.foo.drop()
      true
      > db.foo.update({'a.b':1, 'a.c':1}, {$inc:{z:1}}, true) // Works
      > db.foo.find()
      { "_id" : ObjectId("4f286edcf2d87b48ed83cb08"), "a" : { "b" : 1, "c" : 1 }, "z" : 1 }
      > db.foo.update({'a':{b:1}, 'a.c':1}, {$inc:{z:1}}, true) // Boom!
      > db.foo.find()
      { "_id" : ObjectId("4f286edcf2d87b48ed83cb08"), "a" : { "b" : 1, "c" : 1 }, "z" : 1 }
      { "_id" : ObjectId("4f286efef2d87b48ed83cb09"), "a" : { "b" : 1 }, "a" : { "b" : 1 }, "z" : 1 }
      

      The last one is actually

      {a: {b:1}, a: {c:1}}

      , but printjson function doesn't handle duplicate field names correctly (not sure if it is possible from JS).

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: