From: Mike Bayer Date: Wed, 13 Jun 2012 14:13:17 +0000 (-0400) Subject: dont call connection()/get_bind() all that here if we don't have to X-Git-Tag: rel_0_8_0b1~387 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dfbf68046bc717eb862fa37e4d7207160fe5760e;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git dont call connection()/get_bind() all that here if we don't have to --- diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 6e455d9c76..35a12c2754 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -750,13 +750,15 @@ def _connections_for_states(base_mapper, uowtransaction, states): connection_callable = \ uowtransaction.session.connection_callable else: - connection = uowtransaction.transaction.connection( - base_mapper) + connection = None connection_callable = None for state in _sort_states(states): if connection_callable: connection = connection_callable(base_mapper, state.obj()) + elif not connection: + connection = uowtransaction.transaction.connection( + base_mapper) mapper = _state_mapper(state)