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

Count with hint doesn't work when hint is a document

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.6.3, 2.7.4
    • Fix Version/s: 2.6.6, 2.7.7
    • Component/s: Querying
    • Labels:
      None
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      t = db.jstests_count_hint;
      t.drop();
       
      t.save( { i: 1 } );
      t.save( { i: 2 } );
      assert.eq( 2, t.find().count() );
       
      // create a sparse index which should have no entries
      t.ensureIndex( { x:1 }, { sparse:true } );
       
      assert.eq( 0, t.find( { i: 1 } ).hint( "x_1" ).count(), "A" );
      assert.eq( 0, t.find( { i: 1 } ).hint( {x: 1} ).length(), "B" ); // With just find works
      assert.eq( 0, t.find( { i: 1 } ).hint( {x: 1} ).count(), "C" ); // Fails

      Show
      t = db.jstests_count_hint; t.drop();   t.save( { i: 1 } ); t.save( { i: 2 } ); assert.eq( 2, t.find().count() );   // create a sparse index which should have no entries t.ensureIndex( { x:1 }, { sparse: true } );   assert.eq( 0, t.find( { i: 1 } ).hint( "x_1" ).count(), "A" ); assert.eq( 0, t.find( { i: 1 } ).hint( {x: 1} ).length(), "B" ); // With just find works assert.eq( 0, t.find( { i: 1 } ).hint( {x: 1} ).count(), "C" ); // Fails

      Description

      When using hint() with count() it only works with the string name of the index and not a document representing the index key.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: