From: Mike Bayer Date: Sun, 14 Dec 2014 17:10:56 +0000 (-0500) Subject: - Adjusted the SQLite backend regarding autogen of unique constraints X-Git-Tag: rel_0_7_2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1dab2e30efa1b486d85bf02a0623373615f09db;p=thirdparty%2Fsqlalchemy%2Falembic.git - Adjusted the SQLite backend regarding autogen of unique constraints to work fully with the current SQLAlchemy 1.0, which now will report on UNIQUE constraints that have no name. - fix named foreign key test requirements for SQLAlchemy 1.0 sqlite FK reflection --- diff --git a/alembic/ddl/sqlite.py b/alembic/ddl/sqlite.py index 5894e0f0..16beddf9 100644 --- a/alembic/ddl/sqlite.py +++ b/alembic/ddl/sqlite.py @@ -60,6 +60,13 @@ class SQLiteImpl(DefaultImpl): metadata_unique_constraints, metadata_indexes): + if util.sqla_100: + return + + # adjustments to accommodate for SQLite unnamed unique constraints + # not being reported from the backend; this was updated in + # SQLA 1.0. + def uq_sig(uq): return tuple(sorted(uq.columns.keys())) @@ -74,13 +81,6 @@ class SQLiteImpl(DefaultImpl): if idx.name is None and uq_sig(idx) not in conn_unique_sigs: metadata_unique_constraints.remove(idx) - for idx in list(conn_unique_constraints): - # just in case we fix the backend such that it does report - # on them, blow them out of the reflected collection too otherwise - # they will come up as removed. if the backend supports this now, - # add a version check here for the dialect. - if idx.name is None: - conn_unique_constraints.remove(idx) # @compiles(AddColumn, 'sqlite') # def visit_add_column(element, compiler, **kw): diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index 44e2e070..7cb58452 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -6,6 +6,13 @@ Changelog .. changelog:: :version: 0.7.2 + .. change:: + :tags: bug, sqlite, autogenerate + + Adjusted the SQLite backend regarding autogen of unique constraints + to work fully with the current SQLAlchemy 1.0, which now will report + on UNIQUE constraints that have no name. + .. change:: :tags: bug, batch :tickets: 254 diff --git a/tests/requirements.py b/tests/requirements.py index 47d8bc7e..37fd4e0f 100644 --- a/tests/requirements.py +++ b/tests/requirements.py @@ -1,5 +1,6 @@ from alembic.testing.requirements import SuiteRequirements from alembic.testing import exclusions +from alembic import util class DefaultRequirements(SuiteRequirements): @@ -33,10 +34,11 @@ class DefaultRequirements(SuiteRequirements): @property def no_fk_names(self): """foreign key constraints *never* have names in the DB""" - # TODO: add exclusion SQLAlchemy < 1.0 when - # https://bitbucket.org/zzzeek/sqlalchemy/issue/3261/sqlite-backend-ignores-names-on-reflected - # is fixed - return exclusions.only_on(['sqlite']) + + return exclusions.only_if( + lambda config: exclusions.against(config, "sqlite") + and not util.sqla_100 + ) @property def unnamed_constraints(self):