From 4ae341fc941ff72c1ff8cfcf5ade740a731f161e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 17 Nov 2006 17:03:17 +0000 Subject: [PATCH] added extra pickle unittest to insure update occurs/doesnt occur appropriately --- test/orm/unitofwork.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/orm/unitofwork.py b/test/orm/unitofwork.py index aebb98f57d..9f4e56dd09 100644 --- a/test/orm/unitofwork.py +++ b/test/orm/unitofwork.py @@ -264,6 +264,34 @@ class MutableTypesTest(UnitOfWorkTest): assert f3.data != f1.data assert f3.data == pickleable.Bar(4, 19) + def testmutablechanges(self): + """test that mutable changes are detected or not detected correctly""" + class Foo(object):pass + mapper(Foo, table) + f1 = Foo() + f1.data = pickleable.Bar(4,5) + f1.value = unicode('hi') + ctx.current.flush() + def go(): + ctx.current.flush() + self.assert_sql_count(db, go, 0) + f1.value = unicode('someothervalue') + self.assert_sql(db, lambda: ctx.current.flush(), [ + ( + "UPDATE mutabletest SET value=:value WHERE mutabletest.id = :mutabletest_id", + {'mutabletest_id': 1, 'value': u'someothervalue'} + ), + ]) + f1.value = unicode('hi') + f1.data.x = 9 + self.assert_sql(db, lambda: ctx.current.flush(), [ + ( + "UPDATE mutabletest SET data=:data, value=:value WHERE mutabletest.id = :mutabletest_id", + {'mutabletest_id': 1, 'value': u'hi', 'data':f1.data} + ), + ]) + + def testnocomparison(self): """test that types marked as MutableType get changes detected on them when the type has no __eq__ method""" class Foo(object):pass -- 2.47.2