Details
-
Bug
-
Resolution: Incomplete
-
Minor - P4
-
None
-
None
-
None
-
Server Triage
-
ALL
Description
While performing an academic experiment based on the random generation of a large set of tests to exercise the Query Language of MongoDB (all of which syntactically valid), a possible bug was detected in some preliminary trial tests.
Comparing an array field to an array of values (e.g., {$gt: ["a", "b"] or ["a"]}) instead of a single value (e.g., "a" or "b") on a hint()'ed query returns erroneous results.
- hint()'ing on the _id field (with or without creating a custom index with ensureIndex) returns results but cursor.count() and cursor.size() both return 0.
- hint()'ing on a custom index returns no results and cursor.count() and cursor.size() both return 0.
- without hint()'ing but with the custom index created no results are returned and cursor.count() and cursor.size() both return 0.
- the same query but without hint()'ing and with no custom indexes created results in the array portion of the query being ignored.
Examples:
find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]) results in the same as
find({notArray: {$lt: 1000}}) meaning that the array portion of the query is ignored
-------------------------------------------------------------------------------------------
ensureIndex({notArray: 1})
find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]) no results and cursor.count() and cursor.size() both return 0
find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]).hint("id") shows results in the shell but cursor.count() and cursor.size() both return 0
find($and: [{array: {$gt: [10]}}, {notArray: {$lt: 1000}}]).hint("notArray_1") no results and cursor.count() and cursor.size() both return 0