-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 2.0.0, 2.0.3
-
Component/s: None
-
Labels:None
-
ALL
The $not operator appears to incorrectly distribute over (implicit) conjunctions of operators like $in, $gt, etc.
It appears to treat "not(p and q)" as "not(p) and not(q)" instead of "not(p) or not(q)".
This has only been tested on db versions 2.0.0 and 2.0.3-rc0.
Examples:
// insert some data
db.test.insert(
)
db.test.insert(
)
// Example 1
// not(a > 2 and a < 4)
// a <= 2 or a >= 4
// should yield the row with a = 1
// instead it yields no rows, appearing to do:
// a <= 2 and a >= 4
db.test.find({a:{$not:{$gt:2, $lt:4}}})
// Example 2
// not(a < 2 and a > 4)
// a >= 2 or a <= 4
// should yield both rows (a = 1 and a = 3)
// instead it yields only a = 3, appearing to incorrectly distribute "$not" over the implicit conjunction to get:
// a >= 2 and a <= 4
db.test.find({a:{$not:{$lt:2, $gt:4}}})
- related to
-
DOCS-128 Document the behavior of $not applied to a subdocument containing multiple operators
- Closed