dbmigrate: fix python3 metaclasses error
This commit is contained in:
parent
9027c4ea11
commit
d59ee724df
1 changed files with 33 additions and 1 deletions
|
|
@ -166,7 +166,39 @@ def _to_index(index, table=None, engine=None):
|
|||
return ret
|
||||
|
||||
|
||||
class ColumnDelta(DictMixin, sqlalchemy.schema.SchemaItem):
|
||||
|
||||
# Python3: if we just use:
|
||||
#
|
||||
# class ColumnDelta(DictMixin, sqlalchemy.schema.SchemaItem):
|
||||
# ...
|
||||
#
|
||||
# We get the following error:
|
||||
# TypeError: metaclass conflict: the metaclass of a derived class must be a
|
||||
# (non-strict) subclass of the metaclasses of all its bases.
|
||||
#
|
||||
# The complete inheritance/metaclass relationship list of ColumnDelta can be
|
||||
# summarized by this following dot file:
|
||||
#
|
||||
# digraph test123 {
|
||||
# ColumnDelta -> MutableMapping;
|
||||
# MutableMapping -> Mapping;
|
||||
# Mapping -> {Sized Iterable Container};
|
||||
# {Sized Iterable Container} -> ABCMeta[style=dashed];
|
||||
#
|
||||
# ColumnDelta -> SchemaItem;
|
||||
# SchemaItem -> {SchemaEventTarget Visitable};
|
||||
# SchemaEventTarget -> object;
|
||||
# Visitable -> {VisitableType object} [style=dashed];
|
||||
# VisitableType -> type;
|
||||
# }
|
||||
#
|
||||
# We need to use a metaclass that inherits from all the metaclasses of
|
||||
# DictMixin and sqlalchemy.schema.SchemaItem. Let's call it "MyMeta".
|
||||
class MyMeta(sqlalchemy.sql.visitors.VisitableType, abc.ABCMeta, object):
|
||||
pass
|
||||
|
||||
|
||||
class ColumnDelta(six.with_metaclass(MyMeta, DictMixin, sqlalchemy.schema.SchemaItem)):
|
||||
"""Extracts the differences between two columns/column-parameters
|
||||
|
||||
May receive parameters arranged in several different ways:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue