Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-657

ensure_index returns name of index even when index already exists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial - P5
    • Resolution: Fixed
    • None
    • 2.7
    • None
    • None

    Description

      Documentation states that ensure_index returns None if index already exists:

      Returns the name of the created index if an index is actually
      created. Returns ``None`` if the index already exists.

      In fact, it returns None only if index creation is cached, by pymongo itself. If it isn't cached but index already exists, it does not create it again, but still return name, not None:

              if not self.__database.connection._cached(self.__database.name,
                                                        self.__name, name):
                  return self.create_index(key_or_list, cache_for, **kwargs)
              return None

      (create_index never returns None, according to documentation).

      Attachments

        Activity

          People

            bernie@mongodb.com Bernie Hackett
            kolen Konstantin Mochalov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: