Add __repr__ to pymongo.operations.IndexModel

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Done
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Completed
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Via Tim G,

       
      While checking --debug-sql output, I saw: db.schema_authorcharfieldwithindex.create_indexes([<pymongo.operations.IndexModel object at 0x7fa7285d0370>]) . I thought you might like to add a proper pymongo.operations.IndexModel.{}repr{}()  to improve this output. I'd like to see something like https://github.com/django/django/blob/4d11402932eca570850bdfa58a71eb59fc62275a/django/db/models/indexes.py#L193-L207.
       
      indexes.py
         def {}repr{}(self):
             return "<%s:%s%s%s%s%s%s%s>
      " % (
                 self.{}class{}.{}qualname{},
                 "" if not self.fields else " fields=%s" % repr(self.fields),
                 "" if not self.expressions else " expressions=%s" % repr(self.expressions),Show more
      django/django | Added by GitHub

      Definition of done

       

      _repr_ output is prettier and a test is added to test suite to `test_repr` for `IndexModel`.

      Pitfalls

      None

              Assignee:
              Alex Clark
              Reporter:
              Alex Clark
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: