[entity] fix fetch_rql w/ case where it's called while entity is not 'complete' (eg time where it's being added but have not yet all mandatory relations set) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 17 Aug 2009 11:05:28 +0200
branchstable
changeset 2871 83c5499e1436
parent 2870 e3a5b7c3f767
child 2872 9d641d98cc86
[entity] fix fetch_rql w/ case where it's called while entity is not 'complete' (eg time where it's being added but have not yet all mandatory relations set)
entity.py
--- a/entity.py	Mon Aug 17 10:31:28 2009 +0200
+++ b/entity.py	Mon Aug 17 11:05:28 2009 +0200
@@ -254,8 +254,11 @@
                     selection.pop()
                     restrictions.pop()
                     continue
-                if card == '?':
-                    restrictions[-1] += '?' # left outer join if not mandatory
+                # XXX we need outer join in case the relation is not mandatory
+                # (card == '?')  *or if the entity is being added*, since in
+                # that case the relation may still be missing. As we miss this
+                # later information here, systematically add it.
+                restrictions[-1] += '?'
                 destcls = cls.vreg['etypes'].etype_class(desttype)
                 destcls._fetch_restrictions(var, varmaker, destcls.fetch_attrs,
                                             selection, orderby, restrictions,