From df68f307775a545e067f3a8a3f6bcc9e1f11d9b2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 18 Dec 2007 06:13:42 +0000 Subject: [PATCH] get most oracle tests in sql working again.... --- lib/sqlalchemy/engine/base.py | 13 +++++++++++-- lib/sqlalchemy/sql/compiler.py | 1 + lib/sqlalchemy/sql/functions.py | 5 ++++- test/sql/testtypes.py | 6 ++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 3219e6c5b8..783d60cf44 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1656,8 +1656,17 @@ class BufferedColumnResultProxy(ResultProxy): _process_row = BufferedColumnRow def _get_col(self, row, key): - rec = self._key_cache[key] - return row[rec[2]] + try: + rec = self._key_cache[key] + return row[rec[2]] + except TypeError: + # the 'slice' use case is very infrequent, + # so we use an exception catch to reduce conditionals in _get_col + if isinstance(key, slice): + indices = key.indices(len(row)) + return tuple([self._get_col(row, i) for i in xrange(*indices)]) + else: + raise def fetchall(self): l = [] diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 30b4089d31..2472853847 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -90,6 +90,7 @@ FUNCTIONS = { functions.current_user: 'CURRENT_USER', functions.localtime: 'LOCALTIME', functions.localtimestamp: 'LOCALTIMESTAMP', + functions.sysdate: 'sysdate', functions.session_user :'SESSION_USER', functions.user: 'USER' } diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py index d39032b91c..869df46a7e 100644 --- a/lib/sqlalchemy/sql/functions.py +++ b/lib/sqlalchemy/sql/functions.py @@ -67,6 +67,9 @@ class localtimestamp(AnsiFunction): class session_user(AnsiFunction): __return_type__ = sqltypes.String +class sysdate(AnsiFunction): + __return_type__ = sqltypes.DateTime + class user(AnsiFunction): __return_type__ = sqltypes.String @@ -75,4 +78,4 @@ def _type_from_args(args): if not isinstance(a.type, sqltypes.NullType): return a.type else: - return sqltypes.NullType \ No newline at end of file + return sqltypes.NullType diff --git a/test/sql/testtypes.py b/test/sql/testtypes.py index 073af3e39a..69696ec642 100644 --- a/test/sql/testtypes.py +++ b/test/sql/testtypes.py @@ -73,11 +73,13 @@ class MyPickleType(types.TypeDecorator): impl = PickleType def process_bind_param(self, value, dialect): - value.stuff = 'this is modified stuff' + if value: + value.stuff = 'this is modified stuff' return value def process_result_value(self, value, dialect): - value.stuff = 'this is the right stuff' + if value: + value.stuff = 'this is the right stuff' return value class LegacyType(types.TypeEngine): -- 2.47.3