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" :
}
mongos> db.alex.update(
,{$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"
- is depended on by
-
SERVER-7174 Implement all update() operators
- Closed
-
SERVER-10296 Permit $unset and $rename to manipulate objects with invalid field names (e.g. containing leading $ or .)
- Closed
- is duplicated by
-
SERVER-3231 Upsert with $db is failing
- Closed
-
SERVER-5674 Updates with $ sign in key name fail
- Closed
- is related to
-
SERVER-4448 findAndModify allows invalid field names on update but not insert
- Closed
-
SERVER-9097 okForStorage should be stricter when checking for DBRefs
- Closed
-
SERVER-1991 error message for '.' in key name is too vague in a $set command
- Closed
- related to
-
SERVER-14244 Additional tests for setting fields with $ names
- Closed
-
SERVER-6833 Secondary crashes when replicating a document that the primary accepted (with a field name containing a "$")
- Closed