[SERVER-5067] Update using positional operator fails with indexed query Created: 24/Feb/12  Updated: 11/Jul/16  Resolved: 23/Mar/12

Status: Closed
Project: Core Server
Component/s: Index Maintenance, Write Ops
Affects Version/s: 2.1.0
Fix Version/s: 2.1.1

Type: Bug Priority: Major - P3
Reporter: Phillip Markert Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

64-bit Windows 7


Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Attempting to perform an update operation using the positional operator and an indexed query fails.

I have verified that this same example worked under 2.0.0.

Example: [Starting with an empty database]

MongoDB shell version: 2.1.0
...
> db.test.save( { ArrayField : [

{ Name : "First", Count : 1 }

] } )
> db.test.update(

{ "ArrayField.Name" : "First" }

, { $inc :

{ "ArrayField.$.Count" : 1 }

} )
> db.test.find()
{ "_id" : ObjectId("4f47b2bb78da8386a67102c7"), "ArrayField" : [

{ "Name" : "First", "Count" : 2 }

] }
> db.test.ensureIndex(

{ "ArrayField.Name" : 1 }

)
> db.test.update(

{ "ArrayField.Name" : "First" }

, { $inc :

{ "ArrayField.$.Count" : 1 }

} )
can't append to array using string field name [$]



 Comments   
Comment by auto [ 23/Mar/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-5067 Explicitly request elemMatchKey for update operations with a dynamic array, forcing a full record load on a positive match.
Branch: master
https://github.com/mongodb/mongo/commit/bae4737b585f3e32b893e26dbe65e3e61947a76d

Comment by auto [ 23/Mar/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-5067 Ensure MatchDetails requests are forwarded by the QueryOptimizerCursor.
Branch: master
https://github.com/mongodb/mongo/commit/708047ab122004fdaa6618131d0f24d6d810fb6d

Comment by auto [ 23/Mar/12 ]

Author:

{u'login': u'astaple', u'name': u'Aaron', u'email': u'aaron@10gen.com'}

Message: SERVER-5067 Make elemMatchKey fetching an explicit request in MatchDetails, and use this request to decide if a document load is required.
Branch: master
https://github.com/mongodb/mongo/commit/aa69814d172ab3a6ea04e2af110a8a00494c3ecc

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