summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-06-12 13:08:36 -0400
committerTony Breeds <tony@bakeyournoodle.com>2018-06-15 13:31:38 +1000
commit43af1cf08372006aa46d836ec45482dd4b5b5349 (patch)
tree917930926611d632882005f1fc5745cc7ba6fc9d
parent4c70002578d8ea109a7d0889ab53b9c20bae6ed4 (diff)
downloadoslo-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
-rw-r--r--lower-constraints.txt2
-rw-r--r--oslo_db/sqlalchemy/test_migrations.py20
-rw-r--r--oslo_db/tests/sqlalchemy/test_migrations.py5
-rw-r--r--requirements.txt2
4 files changed, 7 insertions, 22 deletions
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 2aad60b..50fd752 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -1,4 +1,4 @@
-alembic==0.8.10
+alembic==0.9.6
appdirs==1.3.0
Babel==2.3.4
bandit==1.4.0
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'),
diff --git a/requirements.txt b/requirements.txt
index a52b216..4b30c00 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0
-alembic>=0.8.10 # MIT
+alembic>=0.9.6 # MIT
debtcollector>=1.2.0 # Apache-2.0
oslo.i18n>=3.15.3 # Apache-2.0
oslo.config>=5.2.0 # Apache-2.0