Use sha1 to generate index IDs.
This commit is contained in:
parent
1df4b281f9
commit
61b33d9d4f
@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
from itertools import count
|
from itertools import count
|
||||||
|
from hashlib import sha1
|
||||||
|
|
||||||
from sqlalchemy.sql import and_, expression
|
from sqlalchemy.sql import and_, expression
|
||||||
from sqlalchemy.schema import Column, Index
|
from sqlalchemy.schema import Column, Index
|
||||||
@ -272,8 +273,18 @@ class Table(object):
|
|||||||
"""
|
"""
|
||||||
self._check_dropped()
|
self._check_dropped()
|
||||||
if not name:
|
if not name:
|
||||||
sig = abs(hash('||'.join(columns)))
|
sig = '||'.join(columns)
|
||||||
name = 'ix_%s_%s' % (self.table.name, sig)
|
|
||||||
|
# This is a work-around for a bug in <=0.6.1 which would create
|
||||||
|
# indexes based on hash() rather than a proper hash.
|
||||||
|
key = abs(hash(sig))
|
||||||
|
name = 'ix_%s_%s' % (self.table.name, key)
|
||||||
|
if name in self.indexes:
|
||||||
|
return self.indexes[name]
|
||||||
|
|
||||||
|
key = sha1(sig.encode('utf-8')).hexdigest()[:16]
|
||||||
|
name = 'ix_%s_%s' % (self.table.name, key)
|
||||||
|
|
||||||
if name in self.indexes:
|
if name in self.indexes:
|
||||||
return self.indexes[name]
|
return self.indexes[name]
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user