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

XMLWordPrintableJSON

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

      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
              Reporter:
              John Page
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated:
                Resolved: