From 0f322f8a6985d27b1d3b445ab1b271e4147bc719 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 24 Sep 2012 18:09:22 -0500 Subject: [PATCH] db().select(...query.case('true','false)) code cleanup --- VERSION | 2 +- gluon/dal.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index c5823366..7ac93854 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.9 (2012-09-24 18:05:59) stable +Version 2.0.9 (2012-09-24 18:09:19) stable diff --git a/gluon/dal.py b/gluon/dal.py index db50179c..de27e6e7 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -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)))