MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _connections_for_states

Function _connections_for_states

lib/sqlalchemy/orm/persistence.py:1747–1770  ·  view source on GitHub ↗

Return an iterator of (state, state.dict, mapper, connection). The states are sorted according to _sort_states, then paired with the connection they should be using for the given unit of work transaction.

(base_mapper, uowtransaction, states)

Source from the content-addressed store, hash-verified

1745
1746
1747def _connections_for_states(base_mapper, uowtransaction, states):
1748 """Return an iterator of (state, state.dict, mapper, connection).
1749
1750 The states are sorted according to _sort_states, then paired
1751 with the connection they should be using for the given
1752 unit of work transaction.
1753
1754 """
1755 # if session has a connection callable,
1756 # organize individual states with the connection
1757 # to use for update
1758 if uowtransaction.session.connection_callable:
1759 connection_callable = uowtransaction.session.connection_callable
1760 else:
1761 connection = uowtransaction.transaction.connection(base_mapper)
1762 connection_callable = None
1763
1764 for state in _sort_states(base_mapper, states):
1765 if connection_callable:
1766 connection = connection_callable(base_mapper, state.obj())
1767
1768 mapper = state.manager.mapper
1769
1770 yield state, state.dict, mapper, connection
1771
1772
1773def _sort_states(mapper, states):

Callers 3

Calls 2

_sort_statesFunction · 0.85
connectionMethod · 0.45

Tested by

no test coverage detected