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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: 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 }});
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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
            Reporter:
            Norman Graham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: