summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-03-24 01:19:45 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-03-24 01:19:45 +0000
commit533a0ab955c7044dcd8e56a2973599b5b74ab9e8 (patch)
tree7cf17382515bc1e368881d0df657504696cb84ee /lib/sqlalchemy
parent0bb1e1b8e353127b90077ff8a7b9476028f30dc7 (diff)
downloadsqlalchemy-533a0ab955c7044dcd8e56a2973599b5b74ab9e8.tar.gz
- Fixed bug in dynamic_loader() where append/remove events
after construction time were not being propagated to the UOW to pick up on flush(). [ticket:1347]
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/dynamic.py11
-rw-r--r--lib/sqlalchemy/orm/session.py1
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py
index 0de5b98ff..319364910 100644
--- a/lib/sqlalchemy/orm/dynamic.py
+++ b/lib/sqlalchemy/orm/dynamic.py
@@ -19,7 +19,7 @@ from sqlalchemy.orm import (
)
from sqlalchemy.orm.query import Query
from sqlalchemy.orm.util import _state_has_identity, has_identity
-
+from sqlalchemy.orm import attributes
class DynaLoader(strategies.AbstractRelationLoader):
def init_class_attribute(self, mapper):
@@ -70,11 +70,12 @@ class DynamicAttributeImpl(attributes.AttributeImpl):
collection_history = self._modified_event(state)
collection_history.added_items.append(value)
- if self.trackparent and value is not None:
- self.sethasparent(attributes.instance_state(value), True)
for ext in self.extensions:
ext.append(state, value, initiator or self)
+ if self.trackparent and value is not None:
+ self.sethasparent(attributes.instance_state(value), True)
+
def fire_remove_event(self, state, value, initiator):
collection_history = self._modified_event(state)
collection_history.deleted_items.append(value)
@@ -86,10 +87,12 @@ class DynamicAttributeImpl(attributes.AttributeImpl):
ext.remove(state, value, initiator or self)
def _modified_event(self, state):
- state.modified = True
+
if self.key not in state.committed_state:
state.committed_state[self.key] = CollectionHistory(self, state)
+ state.modified_event(self, False, attributes.NEVER_SET, passive=attributes.PASSIVE_NO_INITIALIZE)
+
# this is a hack to allow the _base.ComparableEntity fixture
# to work
state.dict[self.key] = True
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 5e01443a6..d8af4e74f 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1357,6 +1357,7 @@ class Session(object):
not self._deleted and not self._new):
return
+
dirty = self._dirty_states
if not dirty and not self._deleted and not self._new:
self.identity_map.modified = False