fix #1376317: facet: no_relation feature crash when rql has no restriction stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Nov 2010 12:22:42 +0100
branchstable
changeset 6681 674461009c7c
parent 6680 b62ebf1d9388
child 6682 bdf9424b499c
fix #1376317: facet: no_relation feature crash when rql has no restriction
web/facet.py
--- a/web/facet.py	Fri Nov 05 11:58:16 2010 +0100
+++ b/web/facet.py	Fri Nov 05 12:22:42 2010 +0100
@@ -709,9 +709,18 @@
             subj = self.filtered_variable.name
             obj = utils.rqlvar_maker(defined=self.rqlst.defined_vars,
                                      aliases=self.rqlst.aliases).next()
-        rql = 'Any %s LIMIT 1 WHERE NOT %s %s %s, %s' % (
-            self.filtered_variable.name, subj, self.rtype, obj,
-            self.rqlst.where.as_string())
+        restrictions = []
+        if self.rqlst.where:
+            restrictions.append(self.rqlst.where.as_string())
+        if self.rqlst.with_:
+            restrictions.append('WITH ' + ','.join(
+                term.as_string() for term in self.rqlst.with_))
+        if restrictions:
+            restrictions = ',' + ','.join(restrictions)
+        else:
+            restrictions = ''
+        rql = 'Any %s LIMIT 1 WHERE NOT %s %s %s%s' % (
+            self.filtered_variable.name, subj, self.rtype, obj, restrictions)
         try:
             return bool(self.rqlexec(rql, self.cw_rset and self.cw_rset.args))
         except: