[SERVER-997] It is possible to create a field named '$' with the update command. Created: 11/Apr/10  Updated: 09/Apr/14  Resolved: 09/Apr/14

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 1.4.0
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Loïc Faure-Lacroix Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu Server 9.04


Participants:

 Description   

It is possible to created a field named '$' with the update command.

let:
db.menu.update(

{'children.children.label': 'New sub menu'}

, {$push: {'children.$.$.children':

{label: 'New new sub menu', children: []}

}})

where all 'childen' fields are arrays.

Expected result:
the item is pushed at in the right sub children matched by the criteria and 2 level deep because of the positional operator.

Actual Result:
{ "children" : [
{
"$" : {
"children" : [

{ "label" : "New new sub menu", "children" : [ ] }

]
},
},
]
}

On an added note:
update on 'children.$.children' will not add inside

{'$': ...}

 Comments   
Comment by Scott Hernandez (Inactive) [ 09/Apr/14 ]

This is no longer an issue in 2.6 as you will get an error trying to do an update with more than one "$":

db.coll.update( {'children.children.label': 'New sub menu'} , {$push: {'children.$.$.children': {label: 'New new sub menu', children: []} }})
...
	"writeError" : {
		"code" : 2,
		"errmsg" : "Too many positional (i.e. '$') elements found in path 'children.$.$.children'"

Comment by Dwight Merriman [ 12/Jul/11 ]

currently $ is a reserved character

Generated at Thu Feb 08 02:55:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.