mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-06-03 06:19:59 -04:00
removes some unneeded methods, initial DetectKeySwitch not present unnecessarily
This commit is contained in:
@@ -691,26 +691,7 @@ class DetectKeySwitch(DependencyProcessor):
|
||||
if self.prop._reverse_property:
|
||||
return
|
||||
|
||||
if not self.passive_updates:
|
||||
# for non-passive updates, register in the preprocess stage
|
||||
# so that mapper save_obj() gets a hold of changes
|
||||
unitofwork.GetDependentObjects(uow, self, False, False)
|
||||
else:
|
||||
|
||||
##### TODO ########
|
||||
# Get this out of here if self.parent.base_mapper isn't in the flush!!!!
|
||||
|
||||
# for passive updates, register objects in the process stage
|
||||
# so that we avoid ManyToOneDP's registering the object without
|
||||
# the listonly flag in its own preprocess stage (results in UPDATE)
|
||||
# statements being emitted
|
||||
parent_saves = unitofwork.SaveUpdateAll(
|
||||
uow,
|
||||
self.parent.base_mapper)
|
||||
after_save = unitofwork.ProcessAll(uow, self, False, False)
|
||||
uow.dependencies.update([
|
||||
(parent_saves, after_save)
|
||||
])
|
||||
unitofwork.GetDependentObjects(uow, self, False, False)
|
||||
|
||||
def _has_flush_activity(self, uow):
|
||||
pass
|
||||
@@ -721,9 +702,27 @@ class DetectKeySwitch(DependencyProcessor):
|
||||
def presort_deletes(self, uowcommit, states):
|
||||
assert False
|
||||
|
||||
def presort_saves(self, uowcommit, states):
|
||||
assert not self.passive_updates
|
||||
self._process_key_switches(states, uowcommit)
|
||||
def presort_saves(self, uow, states):
|
||||
if self.passive_updates:
|
||||
# for passive updates, register objects in the process stage
|
||||
# so that we avoid ManyToOneDP's registering the object without
|
||||
# the listonly flag in its own preprocess stage (results in UPDATE)
|
||||
# statements being emitted
|
||||
for s in states:
|
||||
if self._pks_changed(uow, s):
|
||||
parent_saves = unitofwork.SaveUpdateAll(
|
||||
uow,
|
||||
self.parent.base_mapper)
|
||||
after_save = unitofwork.ProcessAll(uow, self, False, False)
|
||||
uow.dependencies.update([
|
||||
(parent_saves, after_save)
|
||||
])
|
||||
return
|
||||
|
||||
else:
|
||||
# for non-passive updates, register in the preprocess stage
|
||||
# so that mapper save_obj() gets a hold of changes
|
||||
self._process_key_switches(states, uow)
|
||||
|
||||
def process_deletes(self, uowcommit, states):
|
||||
assert False
|
||||
@@ -767,23 +766,9 @@ class ManyToManyDP(DependencyProcessor):
|
||||
|
||||
def per_property_flush_actions(self, uow):
|
||||
if self._check_reverse(uow):
|
||||
unitofwork.GetDependentObjects(uow, self, False, True)
|
||||
else:
|
||||
DependencyProcessor.per_property_flush_actions(self, uow)
|
||||
return
|
||||
DependencyProcessor.per_property_flush_actions(self, uow)
|
||||
|
||||
def _has_flush_activity(self, uow):
|
||||
if self._check_reverse(uow):
|
||||
return
|
||||
else:
|
||||
DependencyProcessor._has_flush_activity(self, uow)
|
||||
|
||||
def per_state_flush_actions(self, uow, states, isdelete):
|
||||
if self._check_reverse(uow):
|
||||
return
|
||||
else:
|
||||
DependencyProcessor.\
|
||||
per_state_flush_actions(self, uow, states, isdelete)
|
||||
|
||||
def per_property_dependencies(self, uow, parent_saves,
|
||||
child_saves,
|
||||
parent_deletes,
|
||||
|
||||
@@ -224,8 +224,8 @@ class UOWTransaction(object):
|
||||
#sort = topological.sort(self.dependencies, postsort_actions)
|
||||
#print "--------------"
|
||||
#print self.dependencies
|
||||
#print postsort_actions
|
||||
#print "COUNT OF POSTSORT ACTIONS", len(postsort_actions)
|
||||
print postsort_actions
|
||||
print "COUNT OF POSTSORT ACTIONS", len(postsort_actions)
|
||||
|
||||
# execute
|
||||
if self.cycles:
|
||||
@@ -357,18 +357,17 @@ class ProcessAll(PropertyRecMixin, PostSortRec):
|
||||
uow.deps[self.dependency_processor.parent.base_mapper].add(self.dependency_processor)
|
||||
|
||||
def execute(self, uow):
|
||||
states = list(self._elements(uow))
|
||||
states = self._elements(uow)
|
||||
if self.delete:
|
||||
self.dependency_processor.process_deletes(uow, states)
|
||||
else:
|
||||
self.dependency_processor.process_saves(uow, states)
|
||||
|
||||
def per_state_flush_actions(self, uow):
|
||||
# we let the mappers call this,
|
||||
# so that a ProcessAll which is between two mappers that
|
||||
# are part of a cycle (but the ProcessAll itself is not
|
||||
# in the cycle), also becomes a per-state processor,
|
||||
# and a dependency between the two states as well
|
||||
# this is handled by SaveUpdateAll and DeleteAll,
|
||||
# since a ProcessAll should unconditionally be pulled
|
||||
# into per-state if either the parent/child mappers
|
||||
# are part of a cycle
|
||||
return iter([])
|
||||
|
||||
class SaveUpdateAll(PostSortRec):
|
||||
|
||||
@@ -214,6 +214,16 @@ class RudimentaryFlushTest(UOWTest):
|
||||
),
|
||||
)
|
||||
|
||||
def test_m2o_flush_size(self):
|
||||
mapper(User, users)
|
||||
mapper(Address, addresses, properties={
|
||||
'user':relationship(User, passive_updates=True)
|
||||
})
|
||||
sess = create_session()
|
||||
u1 = User(name='ed')
|
||||
sess.add(u1)
|
||||
self._assert_uow_size(sess, 2)
|
||||
|
||||
def test_o2m_flush_size(self):
|
||||
mapper(User, users, properties={
|
||||
'addresses':relationship(Address),
|
||||
|
||||
Reference in New Issue
Block a user