Fix comparison of Variant and other type in test_model_sync
Tests TestModelsMigrations failed on comparation Variant type and BigInteger after alembic 0.8.4 release. Current change corrected compare_type for such case. Closes-bug: #1526675 Co-Authored-By: Ihar Hrachyshka <ihrachys@redhat.com> Change-Id: I7ae7aaf053a81f487d9ec14859700806fa4f9017
This commit is contained in:
parent
ab8adcf693
commit
b8d281a303
|
@ -23,6 +23,7 @@ from oslo_db.sqlalchemy import test_base
|
|||
from oslo_db.sqlalchemy import test_migrations
|
||||
import sqlalchemy
|
||||
from sqlalchemy import event
|
||||
import sqlalchemy.types as types
|
||||
|
||||
from neutron.api.v2 import attributes as attr
|
||||
import neutron.db.migration as migration_help
|
||||
|
@ -134,6 +135,24 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync):
|
|||
def filter_metadata_diff(self, diff):
|
||||
return list(filter(self.remove_unrelated_errors, diff))
|
||||
|
||||
# TODO(akamyshikova): remove this method as soon as comparison with Variant
|
||||
# will be implemented in oslo.db or alembic
|
||||
def compare_type(self, ctxt, insp_col, meta_col, insp_type, meta_type):
|
||||
if isinstance(meta_type, types.Variant):
|
||||
orig_type = meta_col.type
|
||||
meta_col.type = meta_type.impl
|
||||
try:
|
||||
return self.compare_type(ctxt, insp_col, meta_col, insp_type,
|
||||
meta_type.impl)
|
||||
finally:
|
||||
meta_col.type = orig_type
|
||||
else:
|
||||
ret = super(_TestModelsMigrations, self).compare_type(
|
||||
ctxt, insp_col, meta_col, insp_type, meta_type)
|
||||
if ret is not None:
|
||||
return ret
|
||||
return ctxt.impl.compare_type(insp_col, meta_col)
|
||||
|
||||
# Remove some difference that are not mistakes just specific of
|
||||
# dialects, etc
|
||||
def remove_unrelated_errors(self, element):
|
||||
|
|
Loading…
Reference in New Issue