I encountered this on a 2.5.5 nightly, but I imagine the change was introduced somewhere in the 2.5.x branch.
> db.foo.find({ friends: { $elemMatch: { $ref: "people", $id: ObjectId('52b85ca3e84df160228b493b'), $db: "doctrine_odm_tests" } } }) error: { "$err" : "Can't canonicalize query: BadValue unknown top level operator: $ref", "code" : 17287 }
I don't believe there is a case where $elemMatch would have another operator as its immediate child, so perhaps this is just due to how the canonicalizer walks the query object. I noticed that it does not error out for the following queries:
> db.foo.find({ friend: { $ref: "people", $id: ObjectId('52b85ca3e84df160228b493b'), $db: "doctrine_odm_tests" } }) > db.foo.find({ friend: { $in: [{$ref: "people", $id: ObjectId('52b85ca3e84df160228b493b'), $db: "doctrine_odm_tests" }]}})
- related to
-
SERVER-12263 Support $elemMatch with DBRefs that may contain additional properties
- Closed