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] --- test/sql/test_constraints.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'test/sql/test_constraints.py') diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index 5624c0ec6..69f29a9bd 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -183,24 +183,30 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL): def test_too_long_idx_name(self): dialect = testing.db.dialect.__class__() - dialect.max_identifier_length = 22 - for tname, cname, exp in [ - ('sometable', 'this_name_is_too_long', 'ix_sometable_t_09aa'), - ('sometable', 'this_name_alsois_long', 'ix_sometable_t_3cf1'), - ]: + for max_ident, max_index in [(22, None), (256, 22)]: + dialect.max_identifier_length = max_ident + dialect.max_index_name_length = max_index + + for tname, cname, exp in [ + ('sometable', 'this_name_is_too_long', 'ix_sometable_t_09aa'), + ('sometable', 'this_name_alsois_long', 'ix_sometable_t_3cf1'), + ]: - t1 = Table(tname, MetaData(), - Column(cname, Integer, index=True), - ) - ix1 = list(t1.indexes)[0] + t1 = Table(tname, MetaData(), + Column(cname, Integer, index=True), + ) + ix1 = list(t1.indexes)[0] - self.assert_compile( - schema.CreateIndex(ix1), - "CREATE INDEX %s " - "ON %s (%s)" % (exp, tname, cname), - dialect=dialect - ) + self.assert_compile( + schema.CreateIndex(ix1), + "CREATE INDEX %s " + "ON %s (%s)" % (exp, tname, cname), + dialect=dialect + ) + + dialect.max_identifier_length = 22 + dialect.max_index_name_length = None t1 = Table('t', MetaData(), Column('c', Integer)) assert_raises( -- cgit v1.2.1