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

positional operator does not work with negated match expressions

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.10, 2.6.3
    • Component/s: Querying, Write Ops
    • None
    • Query
    • Fully Compatible
    • ALL

      The positional field name is not set when matching a negated expession (eg $ne, $nin, $not). So the $ positional operator does not work for these match expressions.

      Test

      c = db.c;
      c.drop();
      
      // $ operator works with equality match.                                                                 
      c.save( { a:[ 1, 2 ] } );
      c.update( { a:1 }, { $set:{ 'a.$':3 } } );
      printjson( c.findOne() );
      
      // $ operator does not work with $ne match.                                                              
      c.update( { a:{ $ne:10 } }, { $set:{ 'a.$':5 } } );
      printjson( db.getLastError() ); // The '$' field name is not populated.                                  
      printjson( c.findOne() );
      
      // $ operator does not work with $nin match.                                                             
      c.update( { a:{ $nin:[ 10, 20 ] } }, { $set:{ 'a.$':5 } } );
      printjson( db.getLastError() ); // The '$' field name is not populated.                                  
      printjson( c.findOne() );
      
      // $ operator does not work with $not match.                                                             
      c.update( { a:{ $not:{ $gt:7 } } }, { $set:{ 'a.$':5 } } );
      printjson( db.getLastError() ); // The '$' field name is not populated.                                  
      printjson( c.findOne() );
      

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            aaron Aaron Staple
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: