]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
- Adjusted the SQLite backend regarding autogen of unique constraints
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Dec 2014 17:10:56 +0000 (12:10 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 14 Dec 2014 17:10:56 +0000 (12:10 -0500)
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

alembic/ddl/sqlite.py
docs/build/changelog.rst
tests/requirements.py

index 5894e0f08ed54ea43f44d314848983078e2f1409..16beddf90b8c0101ab2107e2b204687f1b91db1f 100644 (file)
@@ -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):
index 44e2e07089516ebc68d168eb1460fbec5408dbd7..7cb58452c6404dad5a74de14f858653502b549ce 100644 (file)
@@ -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
index 47d8bc7e9e852b205539c5c667f9e220357367ee..37fd4e0f75804c2b7f1063af9e985e06eeaaf44a 100644 (file)
@@ -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):