diff options
author | Ann Kamyshnikova <akamyshnikova@mirantis.com> | 2014-09-11 15:03:40 +0400 |
---|---|---|
committer | Ann Kamyshnikova <akamyshnikova@mirantis.com> | 2014-09-15 15:48:09 +0400 |
commit | 436dfdc737cdd1f0d330eac7b3c61b739bf75016 (patch) | |
tree | 0b79e9daaccc01a7f8961e1030ba00d221fd6a7e /oslo | |
parent | cc7ae9fecc705924c4dc1d8d104338afc0e2437e (diff) | |
download | oslo-db-436dfdc737cdd1f0d330eac7b3c61b739bf75016.tar.gz |
ModelsMigrationsSync:add correct server_default check for Enum
If Column which type is Enum has server_default it is compared
incorrectly for PostgreSQL.
For example, Column('test', sa.Enum('one', 'two', name='enum'),
server_default='one').
In model it has DefaultClause('one', for_update=False)) alembic
finds it different from server variant "'one'::enum".
Change-Id: Id30858f9c4c7a2bfb7f9313d47930845fe354a70
Diffstat (limited to 'oslo')
-rw-r--r-- | oslo/db/sqlalchemy/test_migrations.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/oslo/db/sqlalchemy/test_migrations.py b/oslo/db/sqlalchemy/test_migrations.py index 176e0dd..333cd31 100644 --- a/oslo/db/sqlalchemy/test_migrations.py +++ b/oslo/db/sqlalchemy/test_migrations.py @@ -395,7 +395,11 @@ class ModelsMigrationsSync(object): @_compare_server_default.dispatch_for('postgresql') def _compare_server_default(bind, meta_col, insp_def, meta_def): - if isinstance(meta_col.type, sqlalchemy.String): + 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 |