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

Update doesn't support "$"s in the field (not at the start)

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.2
    • Affects Version/s: 2.0.6
    • Component/s: Write Ops
    • None
    • Environment:
      n/a
    • ALL

      Added this in case it's not fixed in later mongodb releases (and I didn't see anything to suggest that it was)

      1] This documentation page suggests that "$" characters should be allowed in the fieldname: http://www.mongodb.org/display/DOCS/Legal+Key+Names

      But:

      mongos> b = { "x": { "string $ string": "test" }}
      { "x" :

      { "string $ string" : "test" }

      }
      mongos> db.alex.update(

      { "_id" : ObjectId("5097edd36ab51b0eece55bb8")}

      ,{$set:b},true)
      not okForStorage

      2] (This isn't just a shell thing, the issue was first noticed from the Java driver with equivalent code)

      3] Note that it only occurs when the field is nested, eg the following works:

      mongos> b =

      { "string $ string": "test" } { "string $ string" : "test" }

      mongos> db.alex.update(

      { "_id" : ObjectId("5097edd36ab51b0eece55bb8")}

      ,{$set:b},true)
      mongos>

      4] Note also that saving/inserting etc works fine, it's just for "update"

            Assignee:
            scotthernandez Scott Hernandez (Inactive)
            Reporter:
            apiggott@ikanow.com Alex Piggott
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: