From 14d2bb074cccdec32bd26a89353c30fd512b2aa2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 10 Sep 2014 14:14:50 -0400 Subject: - Fixed bug in ordering list where the order of items would be thrown off during a collection replace event, if the reorder_on_append flag were set to True. The fix ensures that the ordering list only impacts the list that is explicitly associated with the object. fixes #3191 --- test/orm/test_collection.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/orm') diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index f94c742b3..82331b9af 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -2191,6 +2191,23 @@ class InstrumentationTest(fixtures.ORMTest): f1.attr = l2 eq_(canary, [adapter_1, f1.attr._sa_adapter, None]) + def test_referenced_by_owner(self): + + class Foo(object): + pass + + instrumentation.register_class(Foo) + attributes.register_attribute( + Foo, 'attr', uselist=True, useobject=True) + + f1 = Foo() + f1.attr.append(3) + + adapter = collections.collection_adapter(f1.attr) + assert adapter._referenced_by_owner + + f1.attr = [] + assert not adapter._referenced_by_owner -- cgit v1.2.1