[rset] do not break when rset.related_entity(x,y) is not an entity stable
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Fri, 04 Jun 2010 13:07:07 +0200
branchstable
changeset 5667 04cbd80fd5dc
parent 5666 58d6c2c96500
child 5668 7bd6a8a126b8
[rset] do not break when rset.related_entity(x,y) is not an entity
rset.py
test/unittest_rset.py
--- a/rset.py	Fri Jun 04 11:09:55 2010 +0200
+++ b/rset.py	Fri Jun 04 13:07:07 2010 +0200
@@ -600,7 +600,11 @@
         if rel is not None:
             index = rel.children[0].root_selection_index()
             if index is not None and self.rows[row][index]:
-                return self.get_entity(row, index), rel.r_type
+                try:
+                    entity = self.get_entity(row, index)
+                    return entity, rel.r_type
+                except NotAnEntity, exc:
+                    return None, None
         return None, None
 
     @cached
--- a/test/unittest_rset.py	Fri Jun 04 11:09:55 2010 +0200
+++ b/test/unittest_rset.py	Fri Jun 04 13:07:07 2010 +0200
@@ -397,5 +397,9 @@
                           '(Any X,N WHERE X is CWGroup, X name N)'
                           ')')
 
+    def test_count_users_by_date(self):
+        rset = self.execute('Any D, COUNT(U) GROUPBY D WHERE U is CWUser, U creation_date D')
+        self.assertEquals(rset.related_entity(0,0), (None, None))
+
 if __name__ == '__main__':
     unittest_main()