CAST in sql only when strincly necessary, still, can be better

This commit is contained in:
mdipierro
2013-06-09 17:00:54 -05:00
parent 2444b5c587
commit 09291e0df2
2 changed files with 3 additions and 2 deletions

View File

@@ -1 +1 @@
Version 2.5.1-stable+timestamp.2013.06.09.16.56.30
Version 2.5.1-stable+timestamp.2013.06.09.17.00.11

View File

@@ -1357,7 +1357,8 @@ class BaseAdapter(ConnectionPool):
def expand(self, expression, field_type=None):
if isinstance(expression, Field):
out = '%s.%s' % (expression.tablename, expression.name)
if field_type == 'string':
if field_type == 'string' and not expression.type in (
'string','text','json','password'):
out = 'CAST(%s AS %s)' % (out, self.types['text'])
return out
elif isinstance(expression, (Expression, Query)):