diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-23 19:50:23 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-06-23 19:50:23 -0400 |
commit | f10eb28d90cbf73f4757897f52bf26722f98372e (patch) | |
tree | 0bf86fadcf85b1d254e1ae8bc32dd7db0c0e07d4 /test/orm/test_attributes.py | |
parent | 7e7447db1ff1a49f15269f6515a82607db9384f4 (diff) | |
download | sqlalchemy-f10eb28d90cbf73f4757897f52bf26722f98372e.tar.gz |
- reverse course in #3061 so that we instead no longer set None in the attribute
when we do a get; we return the None as always but we leave the dict blank
and the loader callable still in place. The case for this implicit get on a pending object is not
super common and there really should be no change in state at all when this
operation proceeds. This change is more dramatic as it reverses
a behavior SQLA has had since the first release.
fixes #3061
Diffstat (limited to 'test/orm/test_attributes.py')
-rw-r--r-- | test/orm/test_attributes.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py index ab9b9f5d5..59b0078ea 100644 --- a/test/orm/test_attributes.py +++ b/test/orm/test_attributes.py @@ -949,7 +949,7 @@ class GetNoValueTest(fixtures.ORMTest): attr.get(state, dict_, passive=attributes.PASSIVE_OFF), None ) - assert 'attr' in dict_ + assert 'attr' not in dict_ class UtilTest(fixtures.ORMTest): def test_helpers(self): @@ -2386,7 +2386,7 @@ class LazyloadHistoryTest(fixtures.TestBase): 'bar'), ((), (), ['hi'])) assert f.bar is None eq_(attributes.get_state_history(attributes.instance_state(f), - 'bar'), ([None], (), ['hi'])) + 'bar'), ((), (), ['hi'])) def test_scalar_via_lazyload_with_active(self): # TODO: break into individual tests @@ -2430,7 +2430,7 @@ class LazyloadHistoryTest(fixtures.TestBase): 'bar'), ((), (), ['hi'])) assert f.bar is None eq_(attributes.get_state_history(attributes.instance_state(f), - 'bar'), ([None], (), ['hi'])) + 'bar'), ((), (), ['hi'])) def test_scalar_object_via_lazyload(self): # TODO: break into individual tests @@ -2475,7 +2475,7 @@ class LazyloadHistoryTest(fixtures.TestBase): 'bar'), ((), (), [bar1])) assert f.bar is None eq_(attributes.get_state_history(attributes.instance_state(f), - 'bar'), ([None], (), [bar1])) + 'bar'), ((), (), [bar1])) class ListenerTest(fixtures.ORMTest): def test_receive_changes(self): @@ -2569,11 +2569,8 @@ class ListenerTest(fixtures.ORMTest): f1 = Foo() eq_(f1.bar, None) - eq_(canary.mock_calls, [ - call( - f1, None, attributes.NEVER_SET, - attributes.Event(Foo.bar.impl, attributes.OP_REPLACE)) - ]) + # reversal of approach in #3061 + eq_(canary.mock_calls, []) def test_none_init_object(self): canary = Mock() @@ -2586,11 +2583,23 @@ class ListenerTest(fixtures.ORMTest): f1 = Foo() eq_(f1.bar, None) - eq_(canary.mock_calls, [ - call( - f1, None, attributes.NEVER_SET, - attributes.Event(Foo.bar.impl, attributes.OP_REPLACE)) - ]) + # reversal of approach in #3061 + eq_(canary.mock_calls, []) + + def test_none_init_collection(self): + canary = Mock() + class Foo(object): + pass + instrumentation.register_class(Foo) + attributes.register_attribute(Foo, 'bar', useobject=True, uselist=True) + + event.listen(Foo.bar, "set", canary) + + f1 = Foo() + eq_(f1.bar, []) + # reversal of approach in #3061 + eq_(canary.mock_calls, []) + def test_propagate(self): classes = [None, None, None] |