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

$all:[null] seems to match everything, unless indexed

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

      > c.drop()
      true
      > c.save({c:1})
      > c.save({c:'a'})
      > c.save({c:null})
      > c.save({})
      > c.find({c:{$all:[]}}) // seems to match nothing
      > c.find({c:null}) // matches as expected
      { "_id" : ObjectId("4eec1e9942f62c7f2f5eedee"), "c" : null }
      { "_id" : ObjectId("4eec1e9d42f62c7f2f5eedef") }
      > c.find({c:{$all:[null]}}) // seems to match everything
      { "_id" : ObjectId("4eec1e9542f62c7f2f5eedec"), "c" : 1 }
      { "_id" : ObjectId("4eec1e9742f62c7f2f5eeded"), "c" : "a" }
      { "_id" : ObjectId("4eec1e9942f62c7f2f5eedee"), "c" : null }
      { "_id" : ObjectId("4eec1e9d42f62c7f2f5eedef") }
      > c.find({c:{$all:[1]}})
      { "_id" : ObjectId("4eec1e9542f62c7f2f5eedec"), "c" : 1 }
      > c.ensureIndex({c:1})
      > c.find({c:{$all:[]}})
      > c.find({c:null})
      { "_id" : ObjectId("4eec1e9942f62c7f2f5eedee"), "c" : null }
      { "_id" : ObjectId("4eec1e9d42f62c7f2f5eedef") }
      > c.find({c:{$all:[null]}}) // now matches are bounded by index range
      { "_id" : ObjectId("4eec1e9942f62c7f2f5eedee"), "c" : null }
      { "_id" : ObjectId("4eec1e9d42f62c7f2f5eedef") }
      > c.find({c:{$all:[1]}})
      { "_id" : ObjectId("4eec1e9542f62c7f2f5eedec"), "c" : 1 }
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: