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

Support dotted field past positional operator with positional operator projection

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: Querying
    • Labels:
      None

      Description

      With update the positional operator can be combined with additional fields after the dollar sign, for example 'a.$.b' to indicate the 'b' field within the matched array element. This is not yet supported with positional projections.

      Observed behavior: Projecting

      { 'a.$.b':1 }

      is equivalent to projecting

      { 'a.$':1 }

      .
      Expected behavior: Projecting

      { 'a.$.b':1 }

      will project only the 'b' field within the matching array element.

      Test

      c = db.c;
      c.drop();
       
      c.save( { a:[ { b:10, c:1 }, { b:5, c:1 } ] } );
       
      // Update the 'b' field within the matching array element.
      c.update( { 'a.b':5 }, { $set:{ 'a.$.b':6 } } );
      printjson( c.findOne() );
       
      // Projects the entire matching array element.
      printjson( c.find( { 'a.b':6 }, { 'a.$':1 } ).toArray() );
       
      // Projects the entire matching array element (contrary to expected behavior).
      printjson( c.find( { 'a.b':6 }, { 'a.$.b':1 } ).toArray() );
       
      // Projects the 'b' fields within all array elements.
      printjson( c.find( { 'a.b':6 }, { 'a.b':1 } ).toArray() );

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              backlog-query-optimization Backlog - Query Optimization
              Reporter:
              aaron Aaron Staple
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: