[Sqlalchemy-tickets] [sqlalchemy] #2789: possible approach to the "append/set/clear/remove" attribu
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-07-25 22:48:33
|
#2789: possible approach to the "append/set/clear/remove" attribute event issue
--------------------+------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.0
Component: orm | Severity: major - 1-3 hours
Keywords: | Progress State: not decided upon
--------------------+------------------------------------
{{{
#!diff
diff --git a/lib/sqlalchemy/orm/attributes.py
b/lib/sqlalchemy/orm/attributes.py
index 13c2cf2..166a467 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -960,8 +960,6 @@ class CollectionAttributeImpl(AttributeImpl):
collection.append_with_event(value, initiator)
def remove(self, state, dict_, value, initiator,
passive=PASSIVE_OFF):
- if initiator and initiator.parent_token is self.parent_token:
- return
collection = self.get_collection(state, state.dict,
passive=passive)
if collection is PASSIVE_NO_RESULT:
diff --git a/lib/sqlalchemy/orm/collections.py
b/lib/sqlalchemy/orm/collections.py
index 03917d1..a48369d 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -666,7 +666,6 @@ class CollectionAdapter(object):
def append_with_event(self, item, initiator=None):
"""Add an entity to the collection, firing mutation events."""
-
getattr(self._data(), '_sa_appender')(item,
_sa_initiator=initiator)
def append_without_event(self, item):
diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py
index 4bcecb7..539dff1 100644
--- a/test/orm/test_attributes.py
+++ b/test/orm/test_attributes.py
@@ -1167,7 +1167,7 @@ class BackrefTest(fixtures.ORMTest):
# one level deep. without the parent_token,
# it keeps going until a ValueError is raised
# and this condition changes.
- assert c1 in p1.children
+ assert c1 not in p1.children
class CyclicBackrefAssertionTest(fixtures.TestBase):
"""test that infinite recursion due to incorrect backref assignments
diff --git a/test/orm/test_backref_mutations.py
b/test/orm/test_backref_mutations.py
index 925eedf..74accf5 100644
--- a/test/orm/test_backref_mutations.py
+++ b/test/orm/test_backref_mutations.py
@@ -78,7 +78,7 @@ class O2MCollectionTest(_fixtures.FixtureTest):
# doesn't extend to the previous collection tho,
# which was already loaded.
# flushing at this point means its anyone's guess.
- assert a1 in u1.addresses
+ assert a1 not in u1.addresses
assert a1 in u2.addresses
def test_collection_move_notloaded(self):
@@ -699,9 +699,7 @@ class O2MStaleBackrefTest(_fixtures.FixtureTest):
u1.addresses.append(a1)
u2.addresses.append(a1)
- # events haven't updated
- # u1.addresses here.
- u1.addresses.remove(a1)
+ assert a1 not in u1.addresses
assert a1.user is u2
assert a1 in u2.addresses
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2789>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|