Changes between Initial Version and Version 1 of Ticket #28949, comment 3


Ignore:
Timestamp:
Jan 27, 2018, 6:48:42 AM (6 years ago)
Author:
Abhishek Gautam

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #28949, comment 3

    initial v1  
    1 As we just need a unique name for an index can so, can we create index_name as :
    2 {{{#!python
    3     index_name = '%s%s' % (self._digest(*([table_name] + column_names)), suffix)
    4 }}}
    5 
    6 _digest function will be:
    7 
    8 {{{#!python
    9     @classmethod
    10     def _digest(cls, *args):
    11         """
    12         Generate a 32-bit digest of a set of arguments that can be used to
    13         shorten identifying names.
    14         """
    15         h = hashlib.md5()
    16         for arg in args:
    17             h.update(force_bytes(arg))
    18         return h.hexdigest()
    19 }}}
    20 
    21 Using _digest method we will get 32 byte string and in that we will add suffix which will give us a length of index_name = 32 + length of suffix.
    22 As suffix length will be very small length of index_name will not be able to exceed 40 also.
Back to Top