[schema] ensure DISTINCT is displayed for constraint using it, this ease debugging
--- 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))