diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-24 21:33:07 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-04-24 21:33:07 +0000 |
commit | 49f633b7d11db5a36fa99d53c09620c323374569 (patch) | |
tree | 68a576a262a4d2072b9fef8ecf868330ea7f5602 /lib/sqlalchemy/sql.py | |
parent | 898034c214dbae0c4f11dbd1301d26147dee42ea (diff) | |
download | sqlalchemy-49f633b7d11db5a36fa99d53c09620c323374569.tar.gz |
- fix to case() construct to propigate the type of the first
WHEN condition as the return type of the case statement
- various unit test tweaks to get oracle working
Diffstat (limited to 'lib/sqlalchemy/sql.py')
-rw-r--r-- | lib/sqlalchemy/sql.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py index 1aa9ace9b..f4db66fdf 100644 --- a/lib/sqlalchemy/sql.py +++ b/lib/sqlalchemy/sql.py @@ -331,7 +331,11 @@ def case(whens, value=None, else_=None): whenlist = [_CompoundClause(None, 'WHEN', c, 'THEN', r) for (c,r) in whens] if not else_ is None: whenlist.append(_CompoundClause(None, 'ELSE', else_)) - cc = _CalculatedClause(None, 'CASE', value, *whenlist + ['END']) + if len(whenlist): + type = list(whenlist[-1])[-1].type + else: + type = None + cc = _CalculatedClause(None, 'CASE', value, type=type, *whenlist + ['END']) for c in cc.clauses: c.parens = False return cc @@ -1576,6 +1580,13 @@ class _TextClause(ClauseElement): for b in bindparams: self.bindparams[b.key] = b + def _get_type(self): + if self.typemap is not None and len(self.typemap) == 1: + return list(self.typemap)[0] + else: + return None + type = property(_get_type) + columns = property(lambda s:[]) def get_children(self, **kwargs): |