Merge "Fix accessing SysinvObject optional foreign fields"
This commit is contained in:
commit
a468d5225e
|
@ -1168,7 +1168,8 @@ class DataNetworks(Base):
|
|||
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': 'datanetwork',
|
||||
'polymorphic_on': network_type
|
||||
'polymorphic_on': network_type,
|
||||
'with_polymorphic': '*',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -463,15 +463,15 @@ class SysinvObject(object):
|
|||
def _from_db_object(cls_object, db_object):
|
||||
"""Converts a database entity to a formal object."""
|
||||
for field in cls_object.fields:
|
||||
if field in cls_object._optional_fields:
|
||||
if not hasattr(db_object, field):
|
||||
continue
|
||||
|
||||
if field in cls_object._foreign_fields:
|
||||
cls_object[field] = cls_object._get_foreign_field(
|
||||
field, db_object)
|
||||
continue
|
||||
|
||||
if field in cls_object._optional_fields:
|
||||
if not hasattr(db_object, field):
|
||||
continue
|
||||
|
||||
cls_object[field] = db_object[field]
|
||||
|
||||
cls_object.obj_reset_changes()
|
||||
|
|
Loading…
Reference in New Issue