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

Querying on {$ne:null} on embedded documents within arrays inconsistent between 2.4 and 2.6

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.4
    • Component/s: Querying
    • None
    • ALL
    • Hide
      db.test.insert({ "_id" : 1, "a" : [ { "b" : 2 }, { "b" : 3, "c" : { "d" : 4, "e" : 5 } } ] });
      db.test.find({_id:1,"a.c.d":{$ne:null}});
      db.test.find({_id:1,"a.c.d":{$exists:true}});
      db.test.insert({ "_id" : 2, "a" : [ { "b" : 3, "c" : { "d" : 4, "e" : 5 } } ] });
      db.test.find({_id:2,"a.c.d":{$ne:null}});
      db.test.find({_id:2,"a.c.d":{$exists:true}});
      
      Show
      db.test.insert({ "_id" : 1, "a" : [ { "b" : 2 }, { "b" : 3, "c" : { "d" : 4, "e" : 5 } } ] }); db.test.find({_id:1, "a.c.d" :{$ne: null }}); db.test.find({_id:1, "a.c.d" :{$exists: true }}); db.test.insert({ "_id" : 2, "a" : [ { "b" : 3, "c" : { "d" : 4, "e" : 5 } } ] }); db.test.find({_id:2, "a.c.d" :{$ne: null }}); db.test.find({_id:2, "a.c.d" :{$exists: true }});

      Querying on {$ne:null} on embedded documents within arrays is inconsistent with behavior under 2.4.10. Documents that would normally be matched will fail to match in the presence of subdocuments in the array that do not match the query criteria.

      Workaround is to use {$exists:true} instead.

            Assignee:
            Unassigned Unassigned
            Reporter:
            norman.graham@mongodb.com Norman Graham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: