possibly fixed issue 1446:contains/cast to string problem

This commit is contained in:
mdipierro
2013-06-09 16:41:46 -05:00
parent 4c9967e17e
commit 484b8e5cc9
2 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.5.1-stable+timestamp.2013.06.09.16.30.03
Version 2.5.1-stable+timestamp.2013.06.09.16.41.01
+12 -6
View File
@@ -1309,7 +1309,7 @@ class BaseAdapter(ConnectionPool):
return ftype in ('integer','boolean','double','bigint') or \
ftype.startswith('decimal')
def REPLACE(self, first, (second, third)):
def REPLACE(self, first, (second, third)):
return 'REPLACE(%s,%s,%s)' % (self.expand(first,'string'),
self.expand(second,'string'),
self.expand(third,'string'))
@@ -1356,22 +1356,28 @@ class BaseAdapter(ConnectionPool):
def expand(self, expression, field_type=None):
if isinstance(expression, Field):
return '%s.%s' % (expression.tablename, expression.name)
out = '%s.%s' % (expression.tablename, expression.name)
if field_type == 'string':
out = 'CAST(%s AS %s)' % (out, self.types['text'])
return out
elif isinstance(expression, (Expression, Query)):
first = expression.first
second = expression.second
op = expression.op
optional_args = expression.optional_args or {}
if not second is None:
return op(first, second, **optional_args)
out = op(first, second, **optional_args)
elif not first is None:
return op(first,**optional_args)
out = op(first,**optional_args)
elif isinstance(op, str):
if op.endswith(';'):
op=op[:-1]
return '(%s)' % op
out = '(%s)' % op
else:
return op()
out = op()
if field_type == 'string':
out = 'CAST(%s AS %s)' % (out, self.types['text'])
return out
elif field_type:
return str(self.represent(expression,field_type))
elif isinstance(expression,(list,tuple)):