[SERVER-6588] findAndModify regression 2.0.x -> v2.2.0rc0 with positional updates Created: 25/Jul/12  Updated: 11/Jul/16  Resolved: 01/Aug/12

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.2.0-rc0
Fix Version/s: 2.2.0-rc1

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

Issue Links:
Related
related to SERVER-6993 findAndModify positional operator reg... Closed
Operating System: ALL
Participants:

 Description   

Exepected result: modify the document
Actual result: error.

> db.foo.find()
{ "_id" : ObjectId("5010009b54f3e488821117fc"), "j" : 0, "s" : "abc", "e" : [ { "t" : "a", "c" : 100 } ] }
> db.runCommand( { findAndModify: "foo", query : { s : "abc", j : 0 , 'e.t' : "a" }, update : { $set : { 'e.$.c' : 3 } }  });
{
        "value" : {
                "_id" : ObjectId("5010009b54f3e488821117fc"),
                "j" : 0,
                "s" : "abc",
                "e" : [
                        {
                                "t" : "a",
                                "c" : 100
                        }
                ]
        },
        "errmsg" : "exception: can't append to array using string field name [$]",
        "code" : 13048,
        "ok" : 0
}



 Comments   
Comment by Daniel Pasette (Inactive) [ 12/Sep/12 ]

Thanks jkst. Please see SERVER-6993.

Comment by jkst [ 12/Sep/12 ]

Hi, I've downloaded the latest nightly build (mongodb-linux-x86_64-v2.2-2012-09-11) but it seems that the issue still persists. Please consider the following query on the sample data:

> db.version()
2.2.1-pre-
> printjson(db.MessageRecipients.findOne())
{
"_id" : ObjectId("5050a413f325cf1623538767"),
"MrID" : BinData(3,"swu4J8/E/EuY9kkTnd76XA=="),
"Ph" : "12345678",
"Pr" : 1.2,
"Pts" : [

{ "S" : 5, "MID" : "msg_1", "EC" : 0, "TS" : NumberLong("634830697632037290"), "EMID" : null }

,

{ "S" : 5, "MID" : "msg_2", "EC" : 0, "TS" : NumberLong("634830697632040260"), "EMID" : null }

,

{ "S" : 5, "MID" : "msg_3", "EC" : 0, "TS" : NumberLong("634830697632040340"), "EMID" : null }

]
}
> db.MessageRecipients.findAndModify( { query : { Ph : "12345678", Pts : { $elemMatch : { MID : "msg_2", TS :

{ $lt : new NumberLong("634830697632040340") }

} } }, update : { $set :

{ "Pts.$.S" : 11 }

} } )
Wed Sep 12 19:17:21 uncaught exception: findAndModifyFailed failed: {
"value" : {
"_id" : ObjectId("5050a413f325cf1623538767"),
"MrID" : BinData(3,"swu4J8/E/EuY9kkTnd76XA=="),
"Ph" : "12345678",
"Pr" : 1.2,
"Pts" : [

{ "S" : 5, "MID" : "msg_1", "EC" : 0, "TS" : NumberLong("634830697632037290"), "EMID" : null }

,

{ "S" : 5, "MID" : "msg_2", "EC" : 0, "TS" : NumberLong("634830697632040260"), "EMID" : null }

,

{ "S" : 5, "MID" : "msg_3", "EC" : 0, "TS" : NumberLong("634830697632040340"), "EMID" : null }

]
},
"errmsg" : "exception: can't append to array using string field name [$]",
"code" : 13048,
"ok" : 0
}
>

Comment by auto [ 01/Aug/12 ]

Author:

{u'date': u'2012-07-31T23:04:34-07:00', u'email': u'eliot@10gen.com', u'name': u'Eliot Horowitz'}

Message: SERVER-6588 - fix positional updates in new find_and_modify code
Branch: master
https://github.com/mongodb/mongo/commit/ba7f067a2d5de8832702b4617c3dbf6973e77c5b

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