Fixed returns_typeclass decorator to properly handle filtered query results. Resolves #791.
This commit is contained in:
parent
c28b06d639
commit
1316d8115a
1 changed files with 5 additions and 1 deletions
|
|
@ -41,6 +41,10 @@ def returns_typeclass(method):
|
||||||
def func(self, *args, **kwargs):
|
def func(self, *args, **kwargs):
|
||||||
self.__doc__ = method.__doc__
|
self.__doc__ = method.__doc__
|
||||||
query = method(self, *args, **kwargs)
|
query = method(self, *args, **kwargs)
|
||||||
|
if hasattr(query, "__iter__"):
|
||||||
|
result = list(query)
|
||||||
|
return result[0] if result else None
|
||||||
|
else:
|
||||||
return query
|
return query
|
||||||
return update_wrapper(func, method)
|
return update_wrapper(func, method)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue