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

Incorrect filter result when using a null match inside an indexed array field

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 4.4.4
    • Component/s: None
    • None
    • ALL
    • Hide

      Create the following document inside a random collection:

       

      {"_id":{"$oid":"606717762ce596a43dde9c7b"},"array":[{"value":"MyValue"}]}
      

       

      Run this query:

      { _id: ObjectId('606717762ce596a43dde9c7b'), "array.0.value": null }

      The document will be returned by the database.

      The next query works as expected (no match):

      { _id: ObjectId('606717762ce596a43dde9c7b'), "array.0.value": { $type: "null" } }
      

       

      Show
      Create the following document inside a random collection:   { "_id" :{ "$oid" : "606717762ce596a43dde9c7b" }, "array" :[{ "value" : "MyValue" }]}   Run this query: { _id: ObjectId( '606717762ce596a43dde9c7b' ), "array.0.value" : null } The document will be returned by the database. The next query works as expected (no match): { _id: ObjectId( '606717762ce596a43dde9c7b' ), "array.0.value" : { $type: " null " } }  

      MongoDB v4.4.4 (Atlas).

       

      The database will match more documents than expected when using a null match against an array's item.

       

      Tested with Compass, Robo3T, Mongo shell, and Node.js driver.

            Assignee:
            eric.sedor@mongodb.com Eric Sedor
            Reporter:
            giacomo.gregoletto@evologi.it Giacomo Gregoletto
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: