Skip to content

Commit

Permalink
add debug logs | fix 'Type' setter
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaxxl committed Dec 22, 2024
1 parent cd101e4 commit 3a78617
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions safrs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ def __setattr__(self, attr_name, attr_val):
if is_jsonapi_attr(attr) and attr.fset is None:
# jsonapi_attr.setter not implemented for attr
return attr_val
else:
return super().__setattr__(attr_name, attr_val)
if attr_name == "Type" and hasattr(self, "type"):
# check "Type" property for details
attr_name = "type"
return super().__setattr__(attr_name, attr_val)

def _s_parse_attr_value(self, attr_name: str, attr_val: any):
"""
Expand Down Expand Up @@ -830,6 +832,7 @@ def get_instance(cls, item=None, failsafe=False):
try:
instance = cls._s_query.filter_by(**primary_keys).first()
except Exception as exc: # pragma: no cover
safrs.log.error(f"Failed to get instance with keys {primary_keys}")
raise GenericError(f"get_instance : {exc}")

if not instance and not failsafe:
Expand Down Expand Up @@ -886,7 +889,7 @@ def _s_query(cls_or_self):
safrs.log.warning("Invalid SQLA request")
except Exception as exc:
safrs.log.exception(exc)
safrs.log.error(exc)
safrs.log.error(f"Query failed for {cls_or_self}: {exc}")

if _table:
result = safrs.DB.session.query(_table)
Expand Down Expand Up @@ -1298,8 +1301,7 @@ def Type(self, value):
Type property setter, see comment in the type property
"""
if not self.Type == value:
self.Type = value
self.type = value
self.type = value

@classmethod
def _s_filter(cls, *filter_args, **filter_kwargs):
Expand Down

0 comments on commit 3a78617

Please sign in to comment.