that weren't previously saved in the "mutable changes"
dictionary.
+ - Fixed bug whereby "passive_deletes='all'" wasn't passing
+ the correct symbols to lazy loaders during flush, thereby
+ causing an unwarranted load. [ticket:2013]
+
- Fixed bug which prevented composite mapped
attributes from being used on a mapped select statement.
[ticket:1997]. Note the workings of composite are slated to
self.passive_deletes = prop.passive_deletes
self.passive_updates = prop.passive_updates
self.enable_typechecks = prop.enable_typechecks
+ self._passive_delete_flag = self.passive_deletes and \
+ attributes.PASSIVE_NO_INITIALIZE or \
+ attributes.PASSIVE_OFF
self.key = prop.key
if not self.prop.synchronize_pairs:
raise sa_exc.ArgumentError(
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
for child in history.deleted:
if child is not None and self.hasparent(child) is False:
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
for child in history.deleted:
if child is not None and \
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
if self.cascade.delete_orphan:
todelete = history.sum()
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
ret = True
for child in history.deleted:
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
self._post_update(state, uowcommit, history.sum())
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
def presort_saves(self, uowcommit, states):
if not self.passive_updates:
history = uowcommit.get_attribute_history(
state,
self.key,
- passive=self.passive_deletes)
+ passive=self._passive_delete_flag)
if history:
for child in history.non_added():
if child is None or \
self.states[state] = (isdelete, True)
- def get_attribute_history(self, state, key, passive=True):
+ def get_attribute_history(self, state, key, passive=attributes.PASSIVE_NO_INITIALIZE):
"""facade to attributes.get_state_history(), including caching of results."""
hashkey = ("history", state, key)
@testing.resolve_artifact_names
def test_assertions(self):
mapper(MyOtherClass, myothertable)
- try:
- mapper(MyClass, mytable, properties={
- 'children':relationship(MyOtherClass,
+ assert_raises_message(
+ sa.exc.ArgumentError,
+ "Can't set passive_deletes='all' in conjunction with 'delete' "
+ "or 'delete-orphan' cascade",
+ relationship, MyOtherClass,
passive_deletes='all',
- cascade="all")})
- assert False
- except sa.exc.ArgumentError, e:
- eq_(str(e),
- "Can't set passive_deletes='all' in conjunction with 'delete' "
- "or 'delete-orphan' cascade")
+ cascade="all"
+ )
@testing.resolve_artifact_names
def test_extra_passive(self):
mc.children[0].data = 'some new data'
assert_raises(sa.exc.DBAPIError, session.flush)
+ @testing.resolve_artifact_names
+ def test_dont_emit(self):
+ mapper(MyOtherClass, myothertable)
+ mapper(MyClass, mytable, properties={
+ 'children': relationship(MyOtherClass,
+ passive_deletes='all',
+ cascade="save-update")})
+ session = Session()
+ mc = MyClass()
+ session.add(mc)
+ session.commit()
+ mc.id
+
+ session.delete(mc)
+
+ # no load for "children" should occur
+ self.assert_sql_count(testing.db, session.flush, 1)
class ColumnCollisionTest(_base.MappedTest):
"""Ensure the mapper doesn't break bind param naming rules on flush."""