From b2c0b50bbfa43f662afd16b7ca51bcfe17e4c351 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 2 Aug 2010 01:12:03 -0400 Subject: - 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] --- lib/sqlalchemy/sql/compiler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') 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 -- cgit v1.2.1