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

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 2.6.4
    • 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 }});

    Description

      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.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: