From: Mike Bayer Date: Thu, 4 Dec 2014 18:36:40 +0000 (-0500) Subject: - adjust test here so that it applies to all backends X-Git-Tag: rel_0_7_2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c307d22d32afb2bf32bdaddb6962fdd31910c1f6;p=thirdparty%2Fsqlalchemy%2Falembic.git - adjust test here so that it applies to all backends - skip index at the level of the index, not the columns inside it - changelog - bump for 0.7.2 --- diff --git a/alembic/__init__.py b/alembic/__init__.py index 13678f85..87e57896 100644 --- a/alembic/__init__.py +++ b/alembic/__init__.py @@ -1,6 +1,6 @@ from os import path -__version__ = '0.7.1' +__version__ = '0.7.2' package_dir = path.abspath(path.dirname(__file__)) diff --git a/alembic/ddl/mysql.py b/alembic/ddl/mysql.py index cb9d6349..8be45435 100644 --- a/alembic/ddl/mysql.py +++ b/alembic/ddl/mysql.py @@ -97,13 +97,13 @@ class MySQLImpl(DefaultImpl): # metadata removed = set() for idx in list(conn_indexes): + if idx.unique: + continue # MySQL puts implicit indexes on FK columns, even if # composite and even if MyISAM, so can't check this too easily. # the name of the index may be the column name or it may # be the name of the FK constraint. for col in idx.columns: - if idx.unique: - continue if idx.name == col.name: conn_indexes.remove(idx) removed.add(idx.name) diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index 9a3e0921..8fe52167 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -3,6 +3,19 @@ ========== Changelog ========== +.. changelog:: + :version: 0.7.2 + + .. change:: + :tags: bug, mysql + :tickets: 251 + :pullreq: bitbucket:35 + + Fixed an issue where the MySQL routine to skip foreign-key-implicit + indexes would also catch unnamed unique indexes, as they would be + named after the column and look like the FK indexes. Pull request + courtesy Johannes Erdfelt. + .. changelog:: :version: 0.7.1 :released: December 3, 2014 diff --git a/tests/test_autogen_indexes.py b/tests/test_autogen_indexes.py index e2d9b4ea..95d43afd 100644 --- a/tests/test_autogen_indexes.py +++ b/tests/test_autogen_indexes.py @@ -91,6 +91,25 @@ class AutogenerateUniqueIndexTest(AutogenFixtureTest, TestBase): else: eq_(diffs, []) + def test_unique_flag_nothing_changed(self): + m1 = MetaData() + m2 = MetaData() + + Table('unq_idx', m1, + Column('id', Integer, primary_key=True), + Column('x', String(20)), + Index('x', 'x', unique=True) + ) + + Table('unq_idx', m2, + Column('id', Integer, primary_key=True), + Column('x', String(20)), + Index('x', 'x', unique=True) + ) + + diffs = self._fixture(m1, m2) + eq_(diffs, []) + def test_index_becomes_unique(self): m1 = MetaData() m2 = MetaData() @@ -586,24 +605,6 @@ class MySQLUniqueIndexTest(AutogenerateUniqueIndexTest): else: assert False, "unexpected success" - def test_unique_index_foreign_key(self): - m1 = MetaData() - m2 = MetaData() - - Table('unq_idx', m1, - Column('id', Integer, primary_key=True), - Column('x', String(20)), - Index('x', 'x', unique=True) - ) - - Table('unq_idx', m2, - Column('id', Integer, primary_key=True), - Column('x', String(20)), - Index('x', 'x', unique=True) - ) - - diffs = self._fixture(m1, m2) - eq_(diffs, []) class NoUqReflectionIndexTest(NoUqReflection, AutogenerateUniqueIndexTest):