-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.4.4, 1.5.3
-
Component/s: Index Maintenance, Write Ops
-
None
-
Environment:Debian Linux 32-Bit
-
ALL
Steps to reproduce:
//create initial data
> db.foo.drop();
> db.foo.insert({abc:
, testarray:[
{foobar_id:316, visible:true, xxx: 1}]});
> db.foo.ensureIndex(
);
//it is found correctly
> db.foo.find({'abc.visible':true, testarray:{'$elemMatch':
}});
{ "_id" : ObjectId("4c2c90393a3c2265cd3d1288"), "abc" :
, "testarray" : [
{ "foobar_id" : 316, "visible" : true, "xxx" : 1 } ] }
> db.foo.find({testarray:{'$elemMatch':
}});
{ "_id" : ObjectId("4c2c90393a3c2265cd3d1288"), "abc" :
, "testarray" : [
{ "foobar_id" : 316, "visible" : true, "xxx" : 1 }] }
//update the array
> db.foo.update(
, {'$set': {'testarray.$.visible': true, 'testarray.$.xxx': 2}}, false, true);
//verify it updated correctly
> db.foo.find();
{ "_id" : ObjectId("4c2c90393a3c2265cd3d1288"), "abc" :
, "testarray" : [
{ "foobar_id" : 316, "visible" : true, "xxx" : 2 }] }
//this find still works
> db.foo.find({testarray:{'$elemMatch':
}});
{ "_id" : ObjectId("4c2c90393a3c2265cd3d1288"), "abc" :
, "testarray" : [
{ "foobar_id" : 316, "visible" : true, "xxx" : 2 }] }
//here comes the issue, nothing found here
> db.foo.find({'abc.visible':true, testarray:{'$elemMatch':
}});
//expected: the one entry created above (as 'avc.visible' is still true)
just commands for easy copy&paste:
db.foo.drop();
db.foo.insert({abc:
, testarray:[
{foobar_id:316, visible:true, xxx: 1}]});
db.foo.ensureIndex(
);
db.foo.find({'abc.visible':true, testarray:{'$elemMatch':
}});
db.foo.find({testarray:{'$elemMatch':
}});
db.foo.update(
, {'$set': {'testarray.$.visible': true, 'testarray.$.xxx': 2}}, false, true);
db.foo.find();
db.foo.find({testarray:{'$elemMatch':
}});
db.foo.find({'abc.visible':true, testarray:{'$elemMatch':
}});
renaming one "visible" property is a workaround.