diff options
author | Roman Podolyaka <roman.podolyaka@gmail.com> | 2013-06-08 20:38:02 +0300 |
---|---|---|
committer | Roman Podolyaka <roman.podolyaka@gmail.com> | 2013-06-08 20:56:28 +0300 |
commit | 4cc9d482ae8edc2ac60aaf4102bab84148691fed (patch) | |
tree | a9908dd9af7db38f429c3db168896561cf43b467 /test/dialect/test_mysql.py | |
parent | a341e1ccc9b4d12906f8cb423c45ac2f6f754891 (diff) | |
download | sqlalchemy-4cc9d482ae8edc2ac60aaf4102bab84148691fed.tar.gz |
Fix using of 'mysql_length' for composite indexes
Currently, one can specify the prefix length for an index
column using 'mysql_length' keyword argument when creating
an Index instance. But in case of composite indexes the
prefix length value is applied only to the last column.
Extend the existing API in way so that 'mysql_length' argument
value can be either:
- an integer specifying the same prefix length value
for each column of an index
- a (column_name --> integer value) mapping specifying
the prefix length value for each column of an index
separately
Fixes issue #2704.
Diffstat (limited to 'test/dialect/test_mysql.py')
-rw-r--r-- | test/dialect/test_mysql.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py index 2c459dead..18a37076c 100644 --- a/test/dialect/test_mysql.py +++ b/test/dialect/test_mysql.py @@ -50,6 +50,35 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): 'CREATE INDEX test_idx2 ON testtbl (data(5))', dialect=mysql.dialect()) + def test_create_composite_index_with_length(self): + m = MetaData() + tbl = Table('testtbl', m, + Column('a', String(255)), + Column('b', String(255))) + + idx1 = Index('test_idx1', tbl.c.a, tbl.c.b, + mysql_length={'a': 10, 'b': 20}) + idx2 = Index('test_idx2', tbl.c.a, tbl.c.b, + mysql_length={'a': 15}) + idx3 = Index('test_idx3', tbl.c.a, tbl.c.b, + mysql_length=30) + + self.assert_compile( + schema.CreateIndex(idx1), + 'CREATE INDEX test_idx1 ON testtbl (a(10), b(20))', + dialect=mysql.dialect() + ) + self.assert_compile( + schema.CreateIndex(idx2), + 'CREATE INDEX test_idx2 ON testtbl (a(15), b)', + dialect=mysql.dialect() + ) + self.assert_compile( + schema.CreateIndex(idx3), + 'CREATE INDEX test_idx3 ON testtbl (a(30), b(30))', + dialect=mysql.dialect() + ) + def test_create_index_with_using(self): m = MetaData() tbl = Table('testtbl', m, Column('data', String(255))) |