Pymongo and hint, OperationFailure: database error: bad hint

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.1.1
    • Component/s: None
    • Environment:
      Linux: Ubuntu Lucid
      pymongo : 2.1.1
      Mongo: 2.0.2
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      There is an issue in the latest pymongo driver ( 2.1.1 ) and the usage
      of hint.

      It seems that the hint command refuse any index_name and raise an
      OperationFailure.

      Reading the documentation (http://api.mongodb.org/python/current/api/pymongo/cursor.html?highlight=hint#pymongo.cursor.Cursor.hint) it should be used like this:

      >> cursor.hint([('index_name', pymongo.ASCENDING)])

      but it fail and raise an Exception.

      >> pymongo.errors.OperationFailure: database error: bad hint

      To reproduce the problem I have posted an example here:
      http://nopaste.info/a63201cae6.html.

      The steps to reproduce the Exception are just simple, if you already have a collection, just try to use hint on it with an existing index_name and it will fail.

      You can try the exact same process in the mongo interpreter and it will just work.

            Assignee:
            Bernie Hackett
            Reporter:
            nopz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: