summaryrefslogtreecommitdiff
path: root/test/sql/test_constraints.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-07-21 11:33:47 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-07-21 11:33:47 -0400
commitdabe38bf56dd18876466f07667c386c56ba88de4 (patch)
tree7d4fa21f1b00668defac05dbcb68230ceddea72e /test/sql/test_constraints.py
parent1b0bd4b23f572f581ded0395b78a3371f889ee21 (diff)
downloadsqlalchemy-dabe38bf56dd18876466f07667c386c56ba88de4.tar.gz
- Changed the scheme used to generate truncated
"auto" index names when using the "index=True" flag on Column. The truncation only takes place with the auto-generated name, not one that is user-defined (an error would be raised instead), and the truncation scheme itself is now based on a fragment of an md5 hash of the identifier name, so that multiple indexes on columns with similar names still have unique names. [ticket:1855]
Diffstat (limited to 'test/sql/test_constraints.py')
-rw-r--r--test/sql/test_constraints.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py
index 33e4b8d76..5624c0ec6 100644
--- a/test/sql/test_constraints.py
+++ b/test/sql/test_constraints.py
@@ -183,18 +183,31 @@ class ConstraintTest(TestBase, AssertsExecutionResults, AssertsCompiledSQL):
def test_too_long_idx_name(self):
dialect = testing.db.dialect.__class__()
- dialect.max_identifier_length = 20
+ dialect.max_identifier_length = 22
- t1 = Table("sometable", MetaData(), Column("foo", Integer))
- self.assert_compile(
- schema.CreateIndex(Index("this_name_is_too_long_for_what_were_doing", t1.c.foo)),
- "CREATE INDEX this_name_is_t_1 ON sometable (foo)",
- dialect=dialect
- )
+ for tname, cname, exp in [
+ ('sometable', 'this_name_is_too_long', 'ix_sometable_t_09aa'),
+ ('sometable', 'this_name_alsois_long', 'ix_sometable_t_3cf1'),
+ ]:
- self.assert_compile(
- schema.CreateIndex(Index("this_other_name_is_too_long_for_what_were_doing", t1.c.foo)),
- "CREATE INDEX this_other_nam_1 ON sometable (foo)",
+ 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
+ )
+
+ t1 = Table('t', MetaData(), Column('c', Integer))
+ assert_raises(
+ exc.IdentifierError,
+ schema.CreateIndex(Index(
+ "this_other_name_is_too_long_for_what_were_doing",
+ t1.c.c)).compile,
dialect=dialect
)