Details
-
Bug
-
Resolution: Done
-
Major - P3
-
None
-
None
-
None
-
None
-
Ubuntu 9.10 (on VMWare 6.5.1 under Windows 7)
Description
Bugfix #SERVER-1095 works only for straightforward usage.
We faced that adding $lt condition on integer field to the query of findandmodify operation causes $-operator mismatch.
Here is some code to reproduce the bug:
> db.test.insert( {PhoneNumber:"12345678", MessageParts:[
{PartID:"a", Status:0, Timestamp:123456},
{PartID:"b", Status:0, Timestamp:123456}]} )
> db.test.find()
{ "_id" : ObjectId("4c03d543299e2826314acf56"), "PhoneNumber" : "12345678", "MessageParts" : [
,
{ "PartID" : "b", "Status" : 0, "Timestamp" : 123456 }] }
// Note that we try to conditionally update the second part with ID = "b". In this case item should be updated.
> db.runCommand({findandmodify:"test", query:{PhoneNumber:"12345678", "MessageParts.PartID":"b", "MessageParts.Timestamp":{ $lt:123459 }},
... update:{ $set:
}})
{
"value" : {
"_id" : ObjectId("4c03d543299e2826314acf56"),
"PhoneNumber" : "12345678",
"MessageParts" : [
,
{ "PartID" : "b", "Status" : 0, "Timestamp" : 123456 } ]
},
"ok" : 1
}
// Unexpected behaviour: another item is updated.
> db.test.find()
{ "_id" : ObjectId("4c03d543299e2826314acf56"), "PhoneNumber" : "12345678", "MessageParts" : [
,
{ "PartID" : "b", "Status" : 0, "Timestamp" : 123456 }] }
// without conditions ($lt) everything works fine
> db.runCommand({findandmodify:"test", query:
,
... update: { $set:
} })
{
"value" : {
"_id" : ObjectId("4c03d543299e2826314acf56"),
"PhoneNumber" : "12345678",
"MessageParts" : [
,
{ "PartID" : "b", "Status" : 0, "Timestamp" : 123456 } ]
},
"ok" : 1
}
> db.test.find()
{ "_id" : ObjectId("4c03d543299e2826314acf56"), "PhoneNumber" : "12345678", "MessageParts" : [
,
{ "PartID" : "b", "Status" : 2, "Timestamp" : 123456 }] }
>