summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oslo_db/sqlalchemy/test_migrations.py14
-rw-r--r--oslo_db/tests/sqlalchemy/test_migrations.py5
2 files changed, 18 insertions, 1 deletions
diff --git a/oslo_db/sqlalchemy/test_migrations.py b/oslo_db/sqlalchemy/test_migrations.py
index 9e0f643..4b71048 100644
--- a/oslo_db/sqlalchemy/test_migrations.py
+++ b/oslo_db/sqlalchemy/test_migrations.py
@@ -435,7 +435,19 @@ class ModelsMigrationsSync(object):
if issubclass(type(meta_type), BOOLEAN_METADATA):
return not issubclass(type(insp_type), BOOLEAN_SQL)
- return None # tells alembic to use the default comparison method
+ # Alembic <=0.8.4 do not contain logic of comparing Variant type with
+ # others.
+ if isinstance(meta_type, types.Variant):
+ orig_type = meta_col.type
+ impl_type = meta_type.load_dialect_impl(ctxt.dialect)
+ meta_col.type = impl_type
+ try:
+ return self.compare_type(ctxt, insp_col, meta_col, insp_type,
+ impl_type)
+ finally:
+ meta_col.type = orig_type
+
+ return ctxt.impl.compare_type(insp_col, meta_col)
def compare_server_default(self, ctxt, ins_col, meta_col,
insp_def, meta_def, rendered_meta_def):
diff --git a/oslo_db/tests/sqlalchemy/test_migrations.py b/oslo_db/tests/sqlalchemy/test_migrations.py
index 3df4021..3d97976 100644
--- a/oslo_db/tests/sqlalchemy/test_migrations.py
+++ b/oslo_db/tests/sqlalchemy/test_migrations.py
@@ -199,6 +199,7 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase):
sa.Column('defaulttest4', sa.Enum('first', 'second',
name='testenum'),
server_default="first"),
+ sa.Column('variant', sa.BigInteger()),
sa.Column('fk_check', sa.String(36), nullable=False),
sa.UniqueConstraint('spam', 'eggs', name='uniq_cons'),
)
@@ -227,6 +228,8 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase):
defaulttest4 = sa.Column('defaulttest4', sa.Enum('first', 'second',
name='testenum'),
server_default="first")
+ variant = sa.Column(sa.BigInteger().with_variant(
+ sa.Integer(), 'sqlite'))
bar = sa.Column('bar', sa.Numeric(10, 5))
class ModelThatShouldNotBeCompared(BASE):
@@ -320,6 +323,7 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase):
sa.Column('defaulttest4',
sa.Enum('first', 'second', name='testenum'),
server_default="first"),
+ sa.Column('variant', sa.String(10)),
sa.Column('fk_check', sa.String(36), nullable=False),
sa.UniqueConstraint('spam', 'foo', name='uniq_cons'),
sa.ForeignKeyConstraint(['fk_check'], ['table.fk_check']),
@@ -343,6 +347,7 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase):
self.assertIn('defaulttest', msg)
self.assertIn('defaulttest3', msg)
self.assertIn('remove_fk', msg)
+ self.assertIn('variant', msg)
class ModelsMigrationsSyncMysql(ModelsMigrationSyncMixin,