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

Count behaviour with a bad hint is inconsistent

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Duplicate
    • 2.6.4
    • None
    • 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

        Issue Links

          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: