[SERVER-7557] Update doesn't support "$"s in the field (not at the start) Created: 05/Nov/12  Updated: 11/Jul/16  Resolved: 27/Jul/13

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.0.6
Fix Version/s: 2.5.2

Type: Bug Priority: Major - P3
Reporter: Alex Piggott Assignee: Scott Hernandez (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

n/a


Issue Links:
Depends
is depended on by SERVER-7174 Implement all update() operators Closed
is depended on by SERVER-10296 Permit $unset and $rename to manipula... Closed
Duplicate
is duplicated by SERVER-3231 Upsert with $db is failing Closed
is duplicated by SERVER-5674 Updates with $ sign in key name fail Closed
Related
related to SERVER-14244 Additional tests for setting fields w... Closed
related to SERVER-6833 Secondary crashes when replicating a ... Closed
is related to SERVER-4448 findAndModify allows invalid field na... Closed
is related to SERVER-9097 okForStorage should be stricter when ... Closed
is related to SERVER-1991 error message for '.' in key name is ... Closed
Operating System: ALL
Participants:

 Description   

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"



 Comments   
Comment by auto [ 23/Jul/13 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-7557: fix okForStorage
Branch: master
https://github.com/mongodb/mongo/commit/4211c6a8de32fa774b1c28fb82a96f965fd550b7

Generated at Thu Feb 08 03:14:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.