# HG changeset patch # User Nicolas Chauvat # Date 1275649627 -7200 # Node ID 04cbd80fd5dc2375f7d69814d598642cd989e5a0 # Parent 58d6c2c96500990682aa029ba26840c01c198891 [rset] do not break when rset.related_entity(x,y) is not an entity diff -r 58d6c2c96500 -r 04cbd80fd5dc 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 diff -r 58d6c2c96500 -r 04cbd80fd5dc test/unittest_rset.py --- 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()