post_update_cols=post_update_cols,
single=True)
return
-
+
+ cached_connections = util.PopulateDict(lambda conn:conn.execution_options(
+ compiled_cache=self._compiled_cache.setdefault(conn.engine, {})
+ ))
+
# if session has a connection callable,
# organize individual states with the connection
# to use for insert/update
conn = connection_callable(self, state.obj())
else:
conn = connection
-
+
has_identity = state.has_identity
mapper = _state_mapper(state)
instance_key = state.key or mapper._identity_key_from_state(state)
table_to_mapper = self._sorted_tables
- compiled_cache = self._compiled_cache
-
for table in table_to_mapper:
insert = []
update = []
col not in post_update_cols:
if col in pks:
params[col._label] = \
- mapper._get_state_attr_by_column(state, state_dict, col)
+ mapper._get_state_attr_by_column(
+ state, state_dict, col)
continue
prop = mapper._columntoproperty[col]
if value_params:
c = connection.execute(statement.values(value_params), params)
else:
- c = connection.\
- execution_options(compiled_cache=\
- compiled_cache.setdefault(
- connection.engine, {})
- ).execute(statement, params)
+ c = cached_connections[connection].execute(statement, params)
mapper._postfetch(uowtransaction, table,
state, state_dict, c,
if value_params:
c = connection.execute(statement.values(value_params), params)
else:
- c = connection.\
- execution_options(compiled_cache=\
- compiled_cache.setdefault(
- connection.engine, {})
- ).execute(statement, params)
+ c = cached_connections[connection].execute(statement, params)
primary_key = c.inserted_primary_key
connection_callable = None
tups = []
+ cached_connections = util.PopulateDict(lambda conn:conn.execution_options(
+ compiled_cache=self._compiled_cache.setdefault(conn.engine, {})
+ ))
+
for state in _sort_states(states):
mapper = _state_mapper(state)
table_to_mapper = self._sorted_tables
- compiled_cache = self._compiled_cache
-
for table in reversed(table_to_mapper.keys()):
delete = util.defaultdict(list)
for state, state_dict, mapper, has_identity, connection in tups:
statement = self._memo(('delete', table), delete_stmt)
rows = -1
- connection = connection.execution_options(
- compiled_cache=compiled_cache.setdefault(
- connection.engine,
- {}))
+ connection = cached_connections[connection]
if need_version_id and \
not connection.dialect.supports_sane_multi_rowcount: