From 3b260a3bca8c9af6fc81a122e8696e09802a6881 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 19 Feb 2018 14:01:06 -0500 Subject: [PATCH] Conditionally adjust for quoting in comparing MySQL defaults MariaDB 10.2 appears to not return server defaults with quotes around integer values which breaks the assumption that we have to de-quote server default values. Make the dequoting a regexp that will pass when the quotes are not present. Change-Id: Ie5aeffcc3c550673a7fdd82769a315821cebb272 Closes-bug: #1750414 --- oslo_db/sqlalchemy/test_migrations.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/oslo_db/sqlalchemy/test_migrations.py b/oslo_db/sqlalchemy/test_migrations.py index d650025a..4b8cb128 100644 --- a/oslo_db/sqlalchemy/test_migrations.py +++ b/oslo_db/sqlalchemy/test_migrations.py @@ -476,9 +476,10 @@ class ModelsMigrationsSync(object): if isinstance(meta_col.type, sqlalchemy.Boolean): if meta_def is None or insp_def is None: return meta_def != insp_def + insp_def = insp_def.strip("'") return not ( - isinstance(meta_def.arg, expr.True_) and insp_def == "'1'" or - isinstance(meta_def.arg, expr.False_) and insp_def == "'0'" + isinstance(meta_def.arg, expr.True_) and insp_def == "1" or + isinstance(meta_def.arg, expr.False_) and insp_def == "0" ) impl_type = meta_col.type @@ -487,7 +488,8 @@ class ModelsMigrationsSync(object): 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] + 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):