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

$lt/$gt behaves differently when comparing null

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.3
    • Component/s: Querying
    • Environment:
    • Major Change
    • ALL

      Null is being treated differently by the $gt and $lt operators between versions.

      db.q.drop()
      db.q.insert({"a" : { "a" : 1 } })
      db.q.find( { "b" : { $lt : null } } ).itcount()
      db.q.find( { "b" : { $gt : null } } ).itcount()
      

      2.4.5: 1 doc per query
      2.5.4-Pre: zero doc per query

      Note
      The following queries behave the same on both versions and return zero documents

      db.q.find( { "b" : { $lte : null } } ).itcount()
      db.q.find( { "b" : { $gte : null } } ).itcount()
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: