1. Mike Bayer
  2. alembic

Commits

Mike Bayer  committed 7135c62

- correct for bad booleans coming from SQLA metadata/reflection for the index.unique flag,

  • Participants
  • Parent commits c4e4371
  • Branches master

Comments (0)

Files changed (2)

File alembic/autogenerate/compare.py

View file
         conn_exps = [exp.name for exp in conn_index.expressions]
         meta_exps = [exp.name for exp in meta_index.expressions]
 
-        if meta_index.unique is not conn_index.unique \
+        # convert between both Nones (SQLA ticket #2825) on the metadata
+        # side and zeroes on the reflection side.
+        if bool(meta_index.unique) is not bool(conn_index.unique) \
                 or meta_exps != conn_exps:
             diffs.append(("remove_index", conn_index))
             diffs.append(("add_index", meta_index))

File tests/test_autogenerate.py

View file
 
         Table('address', m,
             Column('id', Integer, primary_key=True),
-            Column('email_address', String(100), nullable=False)
+            Column('email_address', String(100), nullable=False),
+            Column('qpr', String(10), index=True),
         )
 
         Table('order', m,
         Table('address', m,
             Column('id', Integer, primary_key=True),
             Column('email_address', String(100), nullable=False),
+            Column('qpr', String(10), index=True),
             UniqueConstraint("email_address", name="uq_email_address")
         )