possibly fixed issue 1446:contains/cast to string problem
This commit is contained in:
@@ -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
@@ -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)):
|
||||
|
||||
Reference in New Issue
Block a user