summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-04-22 22:17:43 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-04-22 22:17:43 -0400
commit7b2a76c4a3ac49997d1ef0a1a542bd2842abf7c5 (patch)
tree6bb6d0130fce760597c673c04988d7968c89fe96 /lib/sqlalchemy/engine/base.py
parent0c1c6431bc64d98c0bfd517795e2965d32f0968a (diff)
downloadsqlalchemy-7b2a76c4a3ac49997d1ef0a1a542bd2842abf7c5.tar.gz
grumpy fix
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 00eae60a1..31fdd7fb0 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -1640,11 +1640,10 @@ class Connection(Connectable):
try:
# non-DBAPI error - if we already got a context,
# or theres no string statement, don't wrap it
- if not isinstance(e, self.dialect.dbapi.Error) and \
- (statement is None or context is not None):
- return
+ should_wrap = isinstance(e, self.dialect.dbapi.Error) or \
+ (statement is not None and context is None)
- if context:
+ if should_wrap and context:
context.handle_dbapi_exception(e)
is_disconnect = isinstance(e, self.dialect.dbapi.Error) and \
@@ -1658,6 +1657,10 @@ class Connection(Connectable):
self._autorollback()
if self.should_close_with_result:
self.close()
+
+ if not should_wrap:
+ return
+
# Py3K
#raise exc.DBAPIError.instance(
# statement,
@@ -2484,7 +2487,12 @@ class ResultProxy(object):
uses ``returning()``.
"""
- return self.context.rowcount
+ try:
+ return self.context.rowcount
+ except Exception, e:
+ self.connection._handle_dbapi_exception(
+ e, None, None, self.cursor, self.context)
+ raise
@property
def lastrowid(self):
@@ -2501,7 +2509,13 @@ class ResultProxy(object):
regardless of database backend.
"""
- return self._saved_cursor.lastrowid
+ try:
+ return self._saved_cursor.lastrowid
+ except Exception, e:
+ self.connection._handle_dbapi_exception(
+ e, None, None,
+ self._saved_cursor, self.context)
+ raise
@property
def returns_rows(self):