-
Type: Bug
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: 3.4.9
-
Component/s: Querying
-
Query Optimization
-
ALL
Typically, when specifying a field in a query with a mix of operators or exact matches, you will get an error indicating that the operator is unknown. This error is correct in that it would be ambiguous to accept the mixed format when considering how "exact" matches work for values in this syntax.
Expected error:
ermbp:26000(mongod-3.4.6) test> db.test.find({"subfield": {"$lt": 5, "a": 1}}) Error: error: { "ok": 0, "errmsg": "unknown operator: a", "code": 2, "codeName": "BadValue" }
However, specifying a non-operator key first allows one to bypass this error to get behavior that seems like an exact match where the $ field is including in the keys to match.
Failing case:
ermbp:26000(mongod-3.4.6) test> db.test.find({"subfield": {"a": 1, "$lt": 5}}) Fetched 0 record(s) in 0ms