From f5a8fb34d35b0d9daf591155fb7b74ea23fd34b5 Mon Sep 17 00:00:00 2001 From: Ann Kamyshnikova Date: Tue, 12 Apr 2016 11:19:53 +0300 Subject: [PATCH] Fix server_default comparison for BigInteger It is needed to add manual check for server_default parameter for BigInteger as it is already done for Integer. Closes-bug: #1569262 Change-Id: I91b5b3516a6ea0674bc31f3d5a91505fcd927b8b --- oslo_db/sqlalchemy/test_migrations.py | 5 ++++- oslo_db/tests/sqlalchemy/test_migrations.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/oslo_db/sqlalchemy/test_migrations.py b/oslo_db/sqlalchemy/test_migrations.py index 4b710488..df53b855 100644 --- a/oslo_db/sqlalchemy/test_migrations.py +++ b/oslo_db/sqlalchemy/test_migrations.py @@ -481,7 +481,10 @@ class ModelsMigrationsSync(object): isinstance(meta_def.arg, expr.False_) and insp_def == "'0'" ) - if isinstance(meta_col.type, sqlalchemy.Integer): + impl_type = meta_col.type + if isinstance(impl_type, types.Variant): + impl_type = impl_type.load_dialect_impl(bind.dialect) + if isinstance(impl_type, (sqlalchemy.Integer, sqlalchemy.BigInteger)): if meta_def is None or insp_def is None: return meta_def != insp_def return meta_def.arg != insp_def.split("'")[1] diff --git a/oslo_db/tests/sqlalchemy/test_migrations.py b/oslo_db/tests/sqlalchemy/test_migrations.py index 3d97976d..65ad6f81 100644 --- a/oslo_db/tests/sqlalchemy/test_migrations.py +++ b/oslo_db/tests/sqlalchemy/test_migrations.py @@ -200,6 +200,7 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase): name='testenum'), server_default="first"), sa.Column('variant', sa.BigInteger()), + sa.Column('variant2', sa.BigInteger(), server_default='0'), sa.Column('fk_check', sa.String(36), nullable=False), sa.UniqueConstraint('spam', 'eggs', name='uniq_cons'), ) @@ -230,6 +231,8 @@ class ModelsMigrationSyncMixin(test_base.DbTestCase): server_default="first") variant = sa.Column(sa.BigInteger().with_variant( sa.Integer(), 'sqlite')) + variant2 = sa.Column(sa.BigInteger().with_variant( + sa.Integer(), 'sqlite'), server_default='0') bar = sa.Column('bar', sa.Numeric(10, 5)) class ModelThatShouldNotBeCompared(BASE):