Add model_mapper
and model_table
attributes to base importer class
This commit is contained in:
parent
2cfa543e05
commit
739629eab9
|
@ -72,6 +72,22 @@ class Importer(object):
|
|||
"""
|
||||
return self.model_class.__name__
|
||||
|
||||
@property
|
||||
def model_mapper(self):
|
||||
"""
|
||||
This should return the SQLAlchemy mapper for the model class.
|
||||
"""
|
||||
return orm.class_mapper(self.model_class)
|
||||
|
||||
@property
|
||||
def model_table(self):
|
||||
"""
|
||||
Returns the underlying table used by the primary local data model class.
|
||||
"""
|
||||
tables = self.model_mapper.tables
|
||||
assert len(tables) == 1
|
||||
return tables[0]
|
||||
|
||||
@property
|
||||
def simple_fields(self):
|
||||
"""
|
||||
|
@ -80,8 +96,7 @@ class Importer(object):
|
|||
only applies to the local / target side, it has no effect on the
|
||||
upstream / foreign side.
|
||||
"""
|
||||
mapper = orm.class_mapper(self.model_class)
|
||||
return list(mapper.columns.keys())
|
||||
return list(self.model_mapper.columns.keys())
|
||||
|
||||
@property
|
||||
def supported_fields(self):
|
||||
|
|
Loading…
Reference in a new issue