Skip to content

Commit

Permalink
Try cases where related objects have bound methods called id()
Browse files Browse the repository at this point in the history
  • Loading branch information
YinHoon committed Dec 18, 2020
1 parent 83d0cfd commit 1ea6854
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions obj_tables/math/expression.py
Expand Up @@ -1832,6 +1832,14 @@ def get_cls_and_model(self, id):
if cls is not None:
raise ParsedExpressionError(f"multiple models with id='{id}' in expression '{self.expression}'")
cls, model = related_class, related_obj
else:
try: # For cases where the related_obj.id() is a bound method
if related_obj.id() == id:
if cls is not None:
raise ParsedExpressionError(f"multiple models with id='{id}' in expression '{self.expression}'")
cls, model = related_class, related_obj
except TypeError:
pass
return cls, model

def _get_coeffs_for_vars(self):
Expand Down

0 comments on commit 1ea6854

Please sign in to comment.