Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-4965

$not appears to distribute incorrectly over conjunctions

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 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(

      {a:1}

      )
      db.test.insert(

      {a:3}

      )

      // 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}}})

            Assignee:
            Unassigned Unassigned
            Reporter:
            jramish John R
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: