equal
deleted
inserted
replaced
1139 # func_as_sql will check function is supported by the backend |
1139 # func_as_sql will check function is supported by the backend |
1140 return self.dbhelper.func_as_sql(func.name, args) |
1140 return self.dbhelper.func_as_sql(func.name, args) |
1141 |
1141 |
1142 def visit_constant(self, constant): |
1142 def visit_constant(self, constant): |
1143 """generate SQL name for a constant""" |
1143 """generate SQL name for a constant""" |
1144 value = constant.value |
|
1145 if constant.type is None: |
1144 if constant.type is None: |
1146 return 'NULL' |
1145 return 'NULL' |
|
1146 value = constant.value |
1147 if constant.type == 'Int' and isinstance(constant.parent, SortTerm): |
1147 if constant.type == 'Int' and isinstance(constant.parent, SortTerm): |
1148 return constant.value |
1148 return value |
1149 if constant.type in ('Date', 'Datetime'): |
1149 if constant.type in ('Date', 'Datetime'): |
1150 rel = constant.relation() |
1150 rel = constant.relation() |
1151 if rel is not None: |
1151 if rel is not None: |
1152 rel._q_needcast = value |
1152 rel._q_needcast = value |
1153 return self.keyword_map[value]() |
1153 return self.keyword_map[value]() |
1156 if constant.type == 'Substitute': |
1156 if constant.type == 'Substitute': |
1157 try: |
1157 try: |
1158 # we may found constant from simplified var in varmap |
1158 # we may found constant from simplified var in varmap |
1159 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1159 return self._mapped_term(constant, '%%(%s)s' % value)[0] |
1160 except KeyError: |
1160 except KeyError: |
1161 _id = constant.value |
1161 _id = value |
1162 if isinstance(_id, unicode): |
1162 if isinstance(_id, unicode): |
1163 _id = _id.encode() |
1163 _id = _id.encode() |
1164 else: |
1164 else: |
1165 _id = str(id(constant)).replace('-', '', 1) |
1165 _id = str(id(constant)).replace('-', '', 1) |
1166 self._query_attrs[_id] = value |
1166 self._query_attrs[_id] = value |