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

Count behaviour with a bad hint is inconsistent

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor - P4 Minor - P4
    • None
    • 2.6.4
    • Querying
    • None
    • ALL
    • Hide

      collection = db.jstests_count_hint;
      collection.drop();
       
      assert.throws( function() { collection.find( { i: 1 } ).hint( "BAD HINT" ).count(); }, [], "A");
      assert.throws( function() { collection.find().hint( "BAD HINT" ).count(); }, [], "B");
       
      collection.save({i: 1});
      assert.throws( function() { collection.find({ i: 1 }).hint( "BAD HINT" ).count(); }, [], "C");

      Show
      collection = db.jstests_count_hint; collection.drop();   assert.throws( function() { collection.find( { i: 1 } ).hint( "BAD HINT" ).count(); }, [], "A"); assert.throws( function() { collection.find().hint( "BAD HINT" ).count(); }, [], "B");   collection.save({i: 1}); assert.throws( function() { collection.find({ i: 1 }).hint( "BAD HINT" ).count(); }, [], "C");

    Description

      Running a count with an invalid hint may or may not error.

      1. If there are no documents in the collection it won't error
      2. If there are documents but no filter it won't error
      3. If there are documents and a filter it will error

      collection = db.jstests_count_hint;
      collection.drop();
       
      assert.throws( function() { collection.find( { i: 1 } ).hint( "BAD HINT" ).count(); }, [], "A");
      assert.throws( function() { collection.find().hint( "BAD HINT" ).count(); }, [], "B");
       
      collection.save({i: 1});
      assert.throws( function() { collection.find({ i: 1 }).hint( "BAD HINT" ).count(); }, [], "C");

      Only "C" will error.

      Attachments

        Activity

          People

            ramon.fernandez@mongodb.com Ramon Fernandez Marina
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: