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

$all/$elemMatch does not expand arrays to look up fields

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.0-rc0
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Fully Compatible
    • ALL

      For a query like, { 'a.b':{ $all:[ { $elemMatch:

      { c:1 }

      } ] } }, a field named 'a.b' will not be identified if 'a' is an array containing an object with field 'b':

      c = db.c;
      c.drop();
      
      c.save( { a:{ b:[ { c:1 } ] } } );
      printjson( c.find( { 'a.b':{ $all:[ { $elemMatch:{ c:1 } } ] } } ).toArray() );
      
      c.remove();
      c.save( { a:[ { b:[ { c:1 } ] } ] } );
      // Does not match because the implementation does not handle the case where 'a' is an array.
      printjson( c.find( { 'a.b':{ $all:[ { $elemMatch:{ c:1 } } ] } } ).toArray() );
      

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: