Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Don't instantinate a Model if attributes are empty in Foreign relation
Browse files Browse the repository at this point in the history
Adds guard for scenarios where the `Foreign` relationship is passed an
empty set of properties for the target class.
  • Loading branch information
BYK committed Sep 11, 2013
1 parent 1640be8 commit 05de2dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyresto/core.py
Expand Up @@ -405,8 +405,8 @@ def __get__(self, instance, owner):

if instance not in self.__cache:
if self.__embedded:
self.__cache[instance] = self.__model(
**getattr(instance, self.__key_property))
properties = getattr(instance, self.__key_property)
self.__cache[instance] = self.__model(**properties) if properties else None
self.__cache[instance]._auth = instance._auth
else:
self.__cache[instance] = self.__model.get(
Expand Down

0 comments on commit 05de2dc

Please sign in to comment.