diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-03 17:25:26 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-04-03 21:13:08 -0400 |
commit | 9609f5ffb52ce8a4969059e299773ac7176dbb0d (patch) | |
tree | 2baa750e58f1b6df000588e9a63188ff29cfab77 /lib/sqlalchemy/engine/default.py | |
parent | d2c733742f2800264950045905a55e5fc9494a8b (diff) | |
download | sqlalchemy-9609f5ffb52ce8a4969059e299773ac7176dbb0d.tar.gz |
ResultProxy won't autoclose connection until state flag is set
Changed the mechanics of :class:`.ResultProxy` to unconditionally
delay the "autoclose" step until the :class:`.Connection` is done
with the object; in the case where Postgresql ON CONFLICT with
RETURNING returns no rows, autoclose was occurring in this previously
non-existent use case, causing the usual autocommit behavior that
occurs unconditionally upon INSERT/UPDATE/DELETE to fail.
Change-Id: I235a25daf4381b31f523331f810ea04450349722
Fixes: #3955
(cherry picked from commit 8ee363e4917b0dcd64a83b6d26e465c9e61e0ea5)
(cherry picked from commit f52fb5282a046d26b6ee2778e03b995eb117c2ee)
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
-rw-r--r-- | lib/sqlalchemy/engine/default.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 1c10f484f..628e23c9e 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -939,15 +939,15 @@ class DefaultExecutionContext(interfaces.ExecutionContext): row = result.fetchone() self.returned_defaults = row self._setup_ins_pk_from_implicit_returning(row) - result._soft_close(_autoclose_connection=False) + result._soft_close() result._metadata = None elif not self._is_explicit_returning: - result._soft_close(_autoclose_connection=False) + result._soft_close() result._metadata = None elif self.isupdate and self._is_implicit_returning: row = result.fetchone() self.returned_defaults = row - result._soft_close(_autoclose_connection=False) + result._soft_close() result._metadata = None elif result._metadata is None: @@ -955,7 +955,7 @@ class DefaultExecutionContext(interfaces.ExecutionContext): # (which requires open cursor on some drivers # such as kintersbasdb, mxodbc) result.rowcount - result._soft_close(_autoclose_connection=False) + result._soft_close() return result def _setup_ins_pk_from_lastrowid(self): |