entity.py
branchstable
changeset 3672 554a588ffaea
parent 3671 c765adac7f5c
child 3674 387d51af966d
child 3679 983c1af59c2a
--- a/entity.py	Wed Oct 14 17:45:49 2009 +0200
+++ b/entity.py	Thu Oct 15 10:13:52 2009 +0200
@@ -691,14 +691,18 @@
     def related_rql(self, rtype, role='subject', targettypes=None):
         rschema = self.schema[rtype]
         if role == 'subject':
+            restriction = 'E eid %%(x)s, E %s X' % rtype
             if targettypes is None:
                 targettypes = rschema.objects(self.e_schema)
-            restriction = 'E eid %%(x)s, E %s X' % rtype
+            else:
+                restriction += 'E is IN (%s)' % ','.join(targettypes)
             card = greater_card(rschema, (self.e_schema,), targettypes, 0)
         else:
+            restriction = 'E eid %%(x)s, X %s E' % rtype
             if targettypes is None:
                 targettypes = rschema.subjects(self.e_schema)
-            restriction = 'E eid %%(x)s, X %s E' % rtype
+            else:
+                restriction += 'E is IN (%s)' % ','.join(targettypes)
             card = greater_card(rschema, targettypes, (self.e_schema,), 1)
         if len(targettypes) > 1:
             fetchattrs_list = []