[entity] don't look at fetch order recursively
If fetch_attrs includes relations, stop including the entities on the
other side in our sorting. Fixes regression from 73ea636a5562 where we
would sort on the target entity before the attribute we wanted if the
relation's name sorted before the attribute's. This showed up in the
forge/tracker cubes with Version entities being sorted by their State's
name in preference to their version number.
--- a/entity.py Mon Dec 21 10:36:08 2015 +0100
+++ b/entity.py Fri Dec 18 17:49:45 2015 +0100
@@ -378,7 +378,7 @@
else:
fetchattrs = etypecls.fetch_attrs
etypecls._fetch_restrictions(var, select, fetchattrs,
- user, ordermethod, visited=visited)
+ user, None, visited=visited)
if ordermethod is not None:
try:
cmeth = getattr(cls, ordermethod)
--- a/test/unittest_entity.py Mon Dec 21 10:36:08 2015 +0100
+++ b/test/unittest_entity.py Fri Dec 18 17:49:45 2015 +0100
@@ -245,7 +245,7 @@
Personne.fetch_attrs = ('nom', 'prenom', 'travaille')
Societe.fetch_attrs = ('nom', 'evaluee')
self.assertEqual(Personne.fetch_rql(user),
- 'Any X,AA,AB,AC,AD,AE,AF ORDERBY AA,AE DESC '
+ 'Any X,AA,AB,AC,AD,AE,AF ORDERBY AA '
'WHERE X is_instance_of Personne, X nom AA, X prenom AB, X travaille AC?, '
'AC evaluee AD?, AD modification_date AE, AC nom AF')
# testing symmetric relation