MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / UOWTransaction

Class UOWTransaction

lib/sqlalchemy/orm/unitofwork.py:156–488  ·  view source on GitHub ↗

Manages the internal state of a unit of work flush operation.

Source from the content-addressed store, hash-verified

154
155
156class UOWTransaction:
157 """Manages the internal state of a unit of work flush operation."""
158
159 session: Session
160 transaction: SessionTransaction
161 attributes: Dict[str, Any]
162 deps: util.defaultdict[Mapper[Any], Set[_DependencyProcessor]]
163 mappers: util.defaultdict[Mapper[Any], Set[InstanceState[Any]]]
164
165 def __init__(self, session: Session):
166 self.session = session
167
168 # dictionary used by external actors to
169 # store arbitrary state information.
170 self.attributes = {}
171
172 # dictionary of mappers to sets of
173 # DependencyProcessors, which are also
174 # set to be part of the sorted flush actions,
175 # which have that mapper as a parent.
176 self.deps = util.defaultdict(set)
177
178 # dictionary of mappers to sets of InstanceState
179 # items pending for flush which have that mapper
180 # as a parent.
181 self.mappers = util.defaultdict(set)
182
183 # a dictionary of Preprocess objects, which gather
184 # additional states impacted by the flush
185 # and determine if a flush action is needed
186 self.presort_actions = {}
187
188 # dictionary of PostSortRec objects, each
189 # one issues work during the flush within
190 # a certain ordering.
191 self.postsort_actions = {}
192
193 # a set of 2-tuples, each containing two
194 # PostSortRec objects where the second
195 # is dependent on the first being executed
196 # first
197 self.dependencies = set()
198
199 # dictionary of InstanceState-> (isdelete, listonly)
200 # tuples, indicating if this state is to be deleted
201 # or insert/updated, or just refreshed
202 self.states = {}
203
204 # tracks InstanceStates which will be receiving
205 # a "post update" call. Keys are mappers,
206 # values are a set of states and a set of the
207 # columns which should be included in the update.
208 self.post_update_states = util.defaultdict(lambda: (set(), set()))
209
210 @property
211 def has_work(self):
212 return bool(self.states)
213

Callers 1

_flushMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected