Commit 4b17bba1 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[entity] when .related() is called on a not-yet-saved entity, return an empty...

[entity] when .related() is called on a not-yet-saved entity, return an empty rset/list instead of raising an assertion error

--HG--
branch : stable
parent ab03e4adb4f1
......@@ -751,7 +751,10 @@ class Entity(AppObject, dict):
return self.related_cache(rtype, role, entities, limit)
except KeyError:
pass
assert self.has_eid()
if not self.has_eid():
if entities:
return []
return self.empty_rset()
rql = self.related_rql(rtype, role)
rset = self._cw.execute(rql, {'x': self.eid})
self.set_related_cache(rtype, role, rset)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment