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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.6.4
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      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

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              norman.graham Norman Graham
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: