server/sources/rql2sql.py
branchstable
changeset 6286 4d10e9895679
parent 6131 087c5a168010
child 6297 23c1e50ff97b
--- a/server/sources/rql2sql.py	Fri Sep 17 17:25:51 2010 +0200
+++ b/server/sources/rql2sql.py	Fri Sep 17 17:25:58 2010 +0200
@@ -1141,11 +1141,11 @@
 
     def visit_constant(self, constant):
         """generate SQL name for a constant"""
-        value = constant.value
         if constant.type is None:
             return 'NULL'
+        value = constant.value
         if constant.type == 'Int' and  isinstance(constant.parent, SortTerm):
-            return constant.value
+            return value
         if constant.type in ('Date', 'Datetime'):
             rel = constant.relation()
             if rel is not None:
@@ -1158,7 +1158,7 @@
                 # we may found constant from simplified var in varmap
                 return self._mapped_term(constant, '%%(%s)s' % value)[0]
             except KeyError:
-                _id = constant.value
+                _id = value
                 if isinstance(_id, unicode):
                     _id = _id.encode()
         else: