[rql2sql] don't introduce substitution for Int and Boolean constants. This is needed for COUNT(DISTINCT) support stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 27 Jul 2011 12:26:57 +0200
branchstable
changeset 7704 0f49dd8e76b5
parent 7701 e5ba5de1d485
child 7705 2a1f078ebdcd
[rql2sql] don't introduce substitution for Int and Boolean constants. This is needed for COUNT(DISTINCT) support
server/sources/rql2sql.py
--- a/server/sources/rql2sql.py	Tue Jul 26 16:50:06 2011 +0200
+++ b/server/sources/rql2sql.py	Wed Jul 27 12:26:57 2011 +0200
@@ -1438,15 +1438,15 @@
         value = constant.value
         if constant.type == 'etype':
             return value
-        if constant.type == 'Int' and  isinstance(constant.parent, SortTerm):
-            return value
+        if constant.type == 'Int': # XXX Float?
+            return str(value)
         if constant.type in ('Date', 'Datetime'):
             rel = constant.relation()
             if rel is not None:
                 rel._q_needcast = value
             return self.keyword_map[value]()
         if constant.type == 'Boolean':
-            value = self.dbhelper.boolean_value(value)
+            return self.dbhelper.boolean_value(value)
         if constant.type == 'Substitute':
             try:
                 # we may found constant from simplified var in varmap