Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Works as Designed
-
2.2.1
-
None
-
None
-
Tested with 2.2.1 on MacOS X.
-
ALL
Description
If I understand properly, the general rule for doing a query
{'a.x': QUERY}where 'a' is an array is that it should match if there is any element of the 'a' array where
{x: QUERY}matches.
But Mongo 2.2.1 does this:
> db.x.remove({}); db.x.insert({a: [
{x: 1}, {}]})
> db.x.findOne({'a.x': {$exists: false}})
null
> db.x.findOne(
)
null
That surprises me: I'd expect both of these to match, because there is an element of the 'a' array (the {}) such that both {x: {$exists: false}} and
{x: null}matches.
I don't see any relevant tests in the jstests directory asserting that the current behavior is expected. Is this behavior intentional or a bug?