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()))
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):
.. 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
from alembic.testing.requirements import SuiteRequirements
from alembic.testing import exclusions
+from alembic import util
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):