Source

sqlalchemy.mq / resultproxy-exception

# HG changeset patch
# User Philip Jenvey <pjenvey@underboss.org>
# Date 1303526809 25200
# Node ID 63cf1155c876d56927d7f496bc12c100eabf0697
# Parent  c778071d973b96aaf50ddcae8ebb4242b3ace846
ensure proper cleanup if get_result_proxy triggers an Exception

diff -r c778071d973b -r 63cf1155c876 lib/sqlalchemy/engine/base.py
--- a/lib/sqlalchemy/engine/base.py	Fri Apr 22 19:38:39 2011 -0700
+++ b/lib/sqlalchemy/engine/base.py	Fri Apr 22 19:46:49 2011 -0700
@@ -1551,7 +1551,16 @@
 
         # create a resultproxy, get rowcount/implicit RETURNING
         # rows, close cursor if no further results pending
-        result = context.get_result_proxy()
+        try:
+            result = context.get_result_proxy()
+        except Exception, e:
+            self._handle_dbapi_exception(
+                                e,
+                                statement,
+                                parameters,
+                                cursor,
+                                context)
+            raise
 
         if context.isinsert:
             if context._is_implicit_returning: