[schema] ensure DISTINCT is displayed for constraint using it, this ease debugging stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 14 Sep 2010 15:33:01 +0200
branchstable
changeset 6232 d992176d17b7
parent 6231 fd8fb9661c57
child 6233 612b7d947a4c
[schema] ensure DISTINCT is displayed for constraint using it, this ease debugging
schema.py
--- a/schema.py	Tue Sep 14 08:49:29 2010 +0200
+++ b/schema.py	Tue Sep 14 15:33:01 2010 +0200
@@ -613,6 +613,7 @@
 class BaseRQLConstraint(BaseConstraint):
     """base class for rql constraints
     """
+    distinct_query = None
 
     def __init__(self, restriction, mainvars=None):
         self.restriction = normalize_expression(restriction)
@@ -652,8 +653,12 @@
         pass # this is a vocabulary constraint, not enforce XXX why?
 
     def __str__(self):
-        return '%s(Any %s WHERE %s)' % (self.__class__.__name__, self.mainvars,
-                                        self.restriction)
+        if self.distinct_query:
+            selop = 'Any'
+        else:
+            selop = 'DISTINCT Any'
+        return '%s(%s %s WHERE %s)' % (self.__class__.__name__, selop,
+                                       self.mainvars, self.restriction)
 
     def __repr__(self):
         return '<%s @%#x>' % (self.__str__(), id(self))