summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-08-02 01:12:03 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-08-02 01:12:03 -0400
commitb2c0b50bbfa43f662afd16b7ca51bcfe17e4c351 (patch)
treed98573e0d6ed5308cde1c6aa32709afa86f0d7fc /lib/sqlalchemy/sql/compiler.py
parent2f844f231cbcd86dad5d4094565858424ea2c3c7 (diff)
downloadsqlalchemy-b2c0b50bbfa43f662afd16b7ca51bcfe17e4c351.tar.gz
- The generated index name also is based on
a "max index name length" attribute which is separate from the "max identifier length" - this to appease MySQL who has a max length of 64 for index names, separate from their overall max length of 255. [ticket:1412]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 0383f9690..fcff5e355 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1182,8 +1182,10 @@ class DDLCompiler(engine.Compiled):
def _index_identifier(self, ident):
if isinstance(ident, sql._generated_label):
- if len(ident) > self.dialect.max_identifier_length:
- return ident[0:self.dialect.max_identifier_length - 8] + \
+ max = self.dialect.max_index_name_length or \
+ self.dialect.max_identifier_length
+ if len(ident) > max:
+ return ident[0:max - 8] + \
"_" + util.md5_hex(ident)[-4:]
else:
return ident