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

$in doesn't find fields of type undef as null

    • Minor Change
    • ALL
    • v5.0, v4.9, v4.4, v4.2
    • Query Execution 2021-06-14, Query Execution 2021-06-28
    • 160

      If you have a values which is undefined versus null - $in doesnt work

      db.a.insert({x:1,v:null})
      db.a.insert({x:2,v:""})
      db.a.insert({x:3})
      db.a.insert({x:4,v:undefined})
      
      db.a.find(v:null)
      

      Finds all except wher v is ""
      but

      db.a.find(v:{$in:[null,""]})
      

      fails to find the record where x = 4

      A workaround is

      db.u.find({ $or : [ {v:{$type:6}},{v:{$in:[null,""]}}]})
      

      Which is ugly

            Assignee:
            david.storch@mongodb.com David Storch
            Reporter:
            john.page@mongodb.com John Page
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: