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

update() able to create fields which begin with '$'

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.2
    • Affects Version/s: 2.0.2
    • Component/s: Write Ops
    • None
    • Environment:
      OS X 10.6.8
    • ALL

      > db.test.insert({"_id" : 123456, "$push" : "foo"})
      Tue Sep 25 08:53:46 uncaught exception: field names cannot start with $ [$push]
      > db.test.insert({"_id" : 123456})
      > db.test.find()
      { "_id" : 123456 }
      > db.test.update({"_id" : 123456}, {"$set" : { "$push" : "foo" }})
      > db.test.find()
      { "$push" : "foo", "_id" : 123456 }
      > db.test.update({}, {"$rename" : {"$push" : "$"}})
      > db.test.find()
      { "$" : "foo", "_id" : 123456 }
      > db.test.update({}, {"$rename" : "$" : "$$$"}})
      > db.test.find()
      { "$$$" : "foo", "_id" : 123456 }
      

      It seems like the same field name validation rules should be enforced on updates for any modifiers.

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            calebjones Caleb Jones
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: