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

prevent use of positional projection with a simple _id query; assert if a positional projection is requested and no match details are supplied

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
    • ALL

      Observed behavior: A simple query on _id with a positional operator projection on another field returns an incorrect result based on a missing positional match.
      Expected behavior: Same behavior as if it is not a simple query on _id and there is no query field matching the positional operator - uassert.

      Test

      c = db.c;
      c.drop();
      
      c.save( { _id:0, a:[ 1, 2 ] } );
      
      // Throws error.
      c.find( {}, { 'a.$':1 } ).toArray();
      
      // Should throw but instead returns a result I think is incorrect.
      printjson( c.find( { _id:0 }, { 'a.$':1 } ).toArray() );
      

      We should also ensure that in cases where a positional operator is used, a match details is always available. We could check this with an assertion.

            Assignee:
            Unassigned Unassigned
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: