[SERVER-4713] Upsert with $-positional operator can create bad documents Created: 18/Jan/12  Updated: 11/Jul/16  Resolved: 27/Dec/12

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: None
Fix Version/s: 2.3.2

Type: Bug Priority: Major - P3
Reporter: Richard Kreuter (Inactive) Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-6669 update lacking positional match creat... Closed
Operating System: ALL
Participants:

 Description   

From a recent question in training: "what happens if you try to use the positional operator with upsert?". It appears it can create an invalid document with a dollarsign in the field name:

db.foo.update(

{ 'x.a' : 6 }

, { $set :

{ 'x.$.b' : -5 }

}, true )
db.foo.find().pretty()
{
"_id" : ObjectId("4f1724449afa61972cf8ef0b"),
"x" : {
"$" :

{ "b" : -5 }

,
"a" : 6
}
}



 Comments   
Comment by auto [ 27/Dec/12 ]

Author:

{u'date': u'2012-12-22T21:34:06Z', u'email': u'aaron@10gen.com', u'name': u'aaron'}

Message: SERVER-6669 SERVER-4713 Validate that a positional match is found before applying an update mod with the positional operator.
Branch: master
https://github.com/mongodb/mongo/commit/f498a5c235e4da255d9cfea336b66b9c30403706

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