diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2018-06-12 13:08:36 -0400 |
---|---|---|
committer | Tony Breeds <tony@bakeyournoodle.com> | 2018-06-15 13:31:38 +1000 |
commit | 43af1cf08372006aa46d836ec45482dd4b5b5349 (patch) | |
tree | 917930926611d632882005f1fc5745cc7ba6fc9d /oslo_db | |
parent | 4c70002578d8ea109a7d0889ab53b9c20bae6ed4 (diff) | |
download | oslo-db-43af1cf08372006aa46d836ec45482dd4b5b5349.tar.gz |
Remove most server_default comparison logic4.39.0
Added a new test case that covers comparison of a MySQL server default
defined as text("0") in the model as well as in the database. The
MySQL default comaprison logic in oslo.db was not accommodating of the
model side here being a text() construct. As modern Alembic
versions supports most of the use cases tested here,
remove all server defaut comparison logic except for the boolean
comparison workaround.
Alembic minimum is bumped to 0.9.6; the issue repaired between
0.8.10 and 0.9.6 is http://alembic.zzzcomputing.com/en/latest/
changelog.html#change-5459a7552a17d8b658f0f710bedf6da0
Depends-on: I1a8244edae47b04b7b1fed54e577d6534945bcd8
Closes-bug: #1776527
Change-Id: I48a103e28d86128ea84466da4d9d6faab1dd9a9d
Diffstat (limited to 'oslo_db')
-rw-r--r-- | oslo_db/sqlalchemy/test_migrations.py | 20 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_migrations.py | 5 |
2 files changed, 5 insertions, 20 deletions
diff --git a/oslo_db/sqlalchemy/test_migrations.py b/oslo_db/sqlalchemy/test_migrations.py index 4b8cb12..8c8484b 100644 --- a/oslo_db/sqlalchemy/test_migrations.py +++ b/oslo_db/sqlalchemy/test_migrations.py @@ -482,26 +482,6 @@ class ModelsMigrationsSync(object): isinstance(meta_def.arg, expr.False_) and insp_def == "0" ) - 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 - insp_def = insp_def.strip("'") - return meta_def.arg != insp_def - - @_compare_server_default.dispatch_for('postgresql') - def _compare_server_default(bind, meta_col, insp_def, meta_def): - if isinstance(meta_col.type, sqlalchemy.Enum): - if meta_def is None or insp_def is None: - return meta_def != insp_def - return insp_def != "'%s'::%s" % (meta_def.arg, meta_col.type.name) - elif isinstance(meta_col.type, sqlalchemy.String): - if meta_def is None or insp_def is None: - return meta_def != insp_def - return insp_def != "'%s'::character varying" % meta_def.arg - FKInfo = collections.namedtuple('fk_info', ['constrained_columns', 'referred_table', 'referred_columns']) diff --git a/oslo_db/tests/sqlalchemy/test_migrations.py b/oslo_db/tests/sqlalchemy/test_migrations.py index 62cbdfb..17cdf8e 100644 --- a/oslo_db/tests/sqlalchemy/test_migrations.py +++ b/oslo_db/tests/sqlalchemy/test_migrations.py @@ -203,6 +203,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase): sa.Column('defaulttest4', sa.Enum('first', 'second', name='testenum'), server_default="first"), + sa.Column("defaulttest5", sa.Integer, server_default=sa.text('0')), sa.Column('variant', sa.BigInteger()), sa.Column('variant2', sa.BigInteger(), server_default='0'), sa.Column('fk_check', sa.String(36), nullable=False), @@ -233,6 +234,8 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase): defaulttest4 = sa.Column('defaulttest4', sa.Enum('first', 'second', name='testenum'), server_default="first") + defaulttest5 = sa.Column("defaulttest5", + sa.Integer, server_default=sa.text('0')) variant = sa.Column(sa.BigInteger().with_variant( sa.Integer(), 'sqlite')) variant2 = sa.Column(sa.BigInteger().with_variant( @@ -284,6 +287,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase): sa.Column('defaulttest4', sa.Enum('first', 'second', name='testenum'), server_default="first"), + sa.Column("defaulttest5", sa.Integer, server_default=sa.text('0')), sa.Column('fk_check', sa.String(36), nullable=False), sa.UniqueConstraint('spam', 'foo', name='uniq_cons'), sa.ForeignKeyConstraint(['fk_check'], ['table.fk_check']), @@ -330,6 +334,7 @@ class ModelsMigrationSyncMixin(test_base._DbTestCase): sa.Column('defaulttest4', sa.Enum('first', 'second', name='testenum'), server_default="first"), + sa.Column("defaulttest5", sa.Integer, server_default=sa.text('0')), sa.Column('variant', sa.String(10)), sa.Column('fk_check', sa.String(36), nullable=False), sa.UniqueConstraint('spam', 'foo', name='uniq_cons'), |