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

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

    XMLWordPrintableJSON

Details

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

    Description

      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

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: