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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.0.2
    • 2.5.2
    • Write Ops
    • None
    • OS X 10.6.8
    • ALL

    Description

      > 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.

      Attachments

        Issue Links

          Activity

            People

              scotthernandez Scott Hernandez
              calebjones Caleb Jones
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: