[SERVER-39884] Query for null on a field in embedded documents using array index does not work as expected Created: 28/Feb/19  Updated: 28/Feb/19  Resolved: 28/Feb/19

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.6.10
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dani Assignee: Eric Sedor
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-14877 Matcher incorrect on null equality qu... Closed
Operating System: ALL
Steps To Reproduce:

    db.inventory.insertMany([
      { item: "journal", instock: [ { warehouse: "A", qty: 5 } , { warehouse: "C", qty: 15 } ] },
      { item: "notebook", instock: [ { warehouse: "C", qty: 5 } ] },
      { item: "paper", instock: [ { warehouse: null, qty: 60 } , { warehouse: "B", qty: 15 } ] },
      { item: "planner", instock: [ { warehouse: "A", qty: 40 } , { warehouse: "B", qty: 5 } ] },
      { item: "postcard", instock: [ {                qty: 15 } , { warehouse: "C", qty: 35 } ] }
   ]);

 

  • Note that third document has warehouse:null in the first embedded doc and the fifth document has the first embedded doc with no warehouse field.

 

db.inventory.find( { 'instock.0.warehouse': null } )

Returns all five documents where I would expect it to return only third and fifth documents.

 

 

Participants:

 Description   

Matching for null value for a field in embedded documents using array index does not return only the documents that have null value on the field of interest or those that don't have said field present as one would expect... or am I doing something stupid?



 Comments   
Comment by Eric Sedor [ 28/Feb/19 ]

Hi Dani, thanks for your report. This bug is tracked in SERVER-14877. Please watch that ticket for updates.

Generated at Thu Feb 08 04:53:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.