MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / UOWTransaction

Class UOWTransaction

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

Source from the content-addressed store, hash-verified

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

Callers 1

_flushMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected