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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.6.3, 2.7.4
    • 2.6.6, 2.7.7
    • Querying
    • None
    • ALL
    • 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

              david.storch@mongodb.com David Storch
              ross@mongodb.com Ross Lawley
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: