db().select(...query.case('true','false)) code cleanup

This commit is contained in:
mdipierro
2012-09-24 18:09:22 -05:00
parent ec5b4dde6f
commit 0f322f8a69
2 changed files with 3 additions and 5 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.0.9 (2012-09-24 18:05:59) stable
Version 2.0.9 (2012-09-24 18:09:19) stable
+2 -4
View File
@@ -2011,12 +2011,10 @@ class BaseAdapter(ConnectionPool):
def CASE(self,query,t,f):
def represent(x):
types = {type(True):'boolean',type(0):'integer',type(1.0):'double'}
if x is None: return 'NULL'
elif isinstance(x,Expression): return str(x)
types = {type(True): 'boolean',
type(0): 'integer',
type(1.0): 'double'}
return self.represent(x,types.get(type(x),'string'))
else: return self.represent(x,types.get(type(x),'string'))
return Expression(self.db,'CASE WHEN %s THEN %s ELSE %s END' % \
(self.expand(query),represent(t),represent(f)))