From ee7366611bb8b40609f7fa4c3eb1b6db17a92db9 Mon Sep 17 00:00:00 2001 From: Jason Kirtland Date: Mon, 18 Aug 2008 18:57:05 +0000 Subject: [PATCH] attributes.get_history now reports some zero-length slots as the empty tuple rather than an empty list. nice speed boost and memory reduction. --- CHANGES | 42 +++++---- lib/sqlalchemy/orm/attributes.py | 23 +++-- test/orm/attributes.py | 146 +++++++++++++++---------------- test/orm/expire.py | 2 +- test/orm/extendedattr.py | 8 +- 5 files changed, 115 insertions(+), 106 deletions(-) diff --git a/CHANGES b/CHANGES index 50a091daac..093a4b7fed 100644 --- a/CHANGES +++ b/CHANGES @@ -21,7 +21,7 @@ CHANGES scalar subqueries should not "leak" their inner FROM objects out into the enclosing query. - - joins along a relation() from a mapped class to a mapped + - Joins along a relation() from a mapped class to a mapped subclass, where the mapped subclass is configured with single table inheritance, will include an IN clause which limits the subtypes of the joined class to those requsted, within the ON @@ -29,24 +29,23 @@ CHANGES well as query.join(). Note that in some scenarios the IN clause will appear in the WHERE clause of the query as well since this discrimination has multiple trigger points. - - - class.someprop.in_() raises NotImplementedError pending - the implementation of "in_" for relation [ticket:1140] - - - Fixed primary key update for many-to-many collections - where the collection had not been loaded yet - [ticket:1127] - - - The before_flush() hook on SessionExtension takes place - before the list of new/dirty/deleted is calculated for the - final time, allowing routines within before_flush() to - further change the state of the Session before the flush - proceeds. [ticket:1128] - - - Reentrant calls to flush() raise an error. This also - serves as a rudimentary, but not foolproof, check against - concurrent calls to Session.flush(). - + + - class.someprop.in_() raises NotImplementedError pending the + implementation of "in_" for relation [ticket:1140] + + - Fixed primary key update for many-to-many collections where + the collection had not been loaded yet [ticket:1127] + + - The before_flush() hook on SessionExtension takes place before + the list of new/dirty/deleted is calculated for the final + time, allowing routines within before_flush() to further + change the state of the Session before the flush proceeds. + [ticket:1128] + + - Reentrant calls to flush() raise an error. This also serves + as a rudimentary, but not foolproof, check against concurrent + calls to Session.flush(). + - Improved the behavior of query.join() when joining to joined-table inheritance subclasses, using explicit join criteria (i.e. not on a relation). @@ -66,6 +65,11 @@ CHANGES composites with attributes set to None compare correctly. [ticket:1132] + - The 3-tuple of iterables returned by attributes.get_history() + may now be a mix of lists and tuples. (Previously members + were always lists.) + + - sql - Temporarily rolled back the "ORDER BY" enhancement from [ticket:1068]. This feature is on hold pending further diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 2c1da53118..d8f32d6253 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -1306,7 +1306,12 @@ class _ClassInstrumentationAdapter(ClassManager): class History(tuple): - # TODO: migrate [] marker for empty slots to () + """A 3-tuple of added, unchanged and deleted values. + + Each tuple member is an iterable sequence. + + """ + __slots__ = () added = property(itemgetter(0)) @@ -1323,9 +1328,9 @@ class History(tuple): if hasattr(attribute, 'get_collection'): current = attribute.get_collection(state, current) if original is NO_VALUE: - return cls(list(current), [], []) + return cls(list(current), (), ()) elif original is NEVER_SET: - return cls([], list(current), []) + return cls((), list(current), ()) else: collection = util.OrderedIdentitySet(current) s = util.OrderedIdentitySet(original) @@ -1337,20 +1342,20 @@ class History(tuple): if original not in [None, NEVER_SET, NO_VALUE]: deleted = [original] else: - deleted = [] - return cls([], [], deleted) + deleted = () + return cls((), (), deleted) elif original is NO_VALUE: - return cls([current], [], []) + return cls([current], (), ()) elif (original is NEVER_SET or attribute.is_equal(current, original) is True): # dont let ClauseElement expressions here trip things up - return cls([], [current], []) + return cls((), [current], ()) else: if original is not None: deleted = [original] else: - deleted = [] - return cls([current], [], deleted) + deleted = () + return cls([current], (), deleted) class PendingCollection(object): diff --git a/test/orm/attributes.py b/test/orm/attributes.py index 327a3efd3d..eddf48cfe1 100644 --- a/test/orm/attributes.py +++ b/test/orm/attributes.py @@ -334,11 +334,11 @@ class AttributesTest(_base.ORMTest): el = Element() x = Bar() x.element = el - eq_(attributes.get_history(attributes.instance_state(x), 'element'), ([el],[], [])) + eq_(attributes.get_history(attributes.instance_state(x), 'element'), ([el], (), ())) attributes.instance_state(x).commit_all() (added, unchanged, deleted) = attributes.get_history(attributes.instance_state(x), 'element') - assert added == [] + assert added == () assert unchanged == [el] def test_lazyhistory(self): @@ -714,55 +714,55 @@ class HistoryTest(_base.ORMTest): # case 1. new object f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), (), ())) f.someattr = "hi" - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['hi'], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['hi'], (), ())) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['hi'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['hi'], ())) f.someattr = 'there' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['there'], [], ['hi'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['there'], (), ['hi'])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['there'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['there'], ())) del f.someattr - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], ['there'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), (), ['there'])) # case 2. object with direct dictionary settings (similar to a load operation) f = Foo() f.__dict__['someattr'] = 'new' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['new'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['new'], ())) f.someattr = 'old' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['old'], [], ['new'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['old'], (), ['new'])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['old'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['old'], ())) # setting None on uninitialized is currently a change for a scalar attribute # no lazyload occurs so this allows overwrite operation to proceed f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), (), ())) f.someattr = None - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], (), ())) f = Foo() f.__dict__['someattr'] = 'new' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['new'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['new'], ())) f.someattr = None - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], [], ['new'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], (), ['new'])) # set same value twice f = Foo() attributes.instance_state(f).commit(['someattr']) f.someattr = 'one' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['one'], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['one'], (), ())) f.someattr = 'two' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['two'], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['two'], (), ())) def test_mutable_scalar(self): @@ -774,33 +774,33 @@ class HistoryTest(_base.ORMTest): # case 1. new object f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), (), ())) f.someattr = {'foo':'hi'} - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'hi'}], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'hi'}], (), ())) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [{'foo':'hi'}], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [{'foo':'hi'}], ())) eq_(attributes.instance_state(f).committed_state['someattr'], {'foo':'hi'}) f.someattr['foo'] = 'there' eq_(attributes.instance_state(f).committed_state['someattr'], {'foo':'hi'}) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'there'}], [], [{'foo':'hi'}])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'there'}], (), [{'foo':'hi'}])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [{'foo':'there'}], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [{'foo':'there'}], ())) # case 2. object with direct dictionary settings (similar to a load operation) f = Foo() f.__dict__['someattr'] = {'foo':'new'} - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [{'foo':'new'}], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [{'foo':'new'}], ())) f.someattr = {'foo':'old'} - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'old'}], [], [{'foo':'new'}])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([{'foo':'old'}], (), [{'foo':'new'}])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [{'foo':'old'}], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [{'foo':'old'}], ())) def test_use_object(self): @@ -822,56 +822,56 @@ class HistoryTest(_base.ORMTest): # case 1. new object f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [None], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [None], ())) f.someattr = hi - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], (), ())) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [hi], ())) f.someattr = there - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([there], [], [hi])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([there], (), [hi])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [there], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [there], ())) del f.someattr - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], [], [there])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], (), [there])) # case 2. object with direct dictionary settings (similar to a load operation) f = Foo() f.__dict__['someattr'] = 'new' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['new'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['new'], ())) f.someattr = old - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([old], [], ['new'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([old], (), ['new'])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [old], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [old], ())) # setting None on uninitialized is currently not a change for an object attribute # (this is different than scalar attribute). a lazyload has occured so if its # None, its really None f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [None], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [None], ())) f.someattr = None - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [None], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [None], ())) f = Foo() f.__dict__['someattr'] = 'new' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], ['new'], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), ['new'], ())) f.someattr = None - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], [], ['new'])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([None], (), ['new'])) # set same value twice f = Foo() attributes.instance_state(f).commit(['someattr']) f.someattr = 'one' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['one'], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['one'], (), ())) f.someattr = 'two' - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['two'], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), (['two'], (), ())) def test_object_collections_set(self): class Foo(_base.BasicEntity): @@ -890,20 +890,20 @@ class HistoryTest(_base.ORMTest): # case 1. new object f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [], ())) f.someattr = [hi] eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], [], [])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [hi], ())) f.someattr = [there] eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([there], [], [hi])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [there], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [there], ())) f.someattr = [hi] eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], [], [there])) @@ -916,13 +916,13 @@ class HistoryTest(_base.ORMTest): collection = attributes.init_collection(attributes.instance_state(f), 'someattr') collection.append_without_event(new) attributes.instance_state(f).commit_all() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [new], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [new], ())) f.someattr = [old] eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([old], [], [new])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [old], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [old], ())) def test_dict_collections(self): class Foo(_base.BasicEntity): @@ -941,16 +941,16 @@ class HistoryTest(_base.ORMTest): new = Bar(name='new') f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [], ())) f.someattr['hi'] = hi eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], [], [])) f.someattr['there'] = there - eq_(tuple([set(x) for x in attributes.get_history(attributes.instance_state(f), 'someattr')]), (set([hi, there]), set([]), set([]))) + eq_(tuple([set(x) for x in attributes.get_history(attributes.instance_state(f), 'someattr')]), (set([hi, there]), set(), set())) attributes.instance_state(f).commit(['someattr']) - eq_(tuple([set(x) for x in attributes.get_history(attributes.instance_state(f), 'someattr')]), (set([]), set([hi, there]), set([]))) + eq_(tuple([set(x) for x in attributes.get_history(attributes.instance_state(f), 'someattr')]), (set(), set([hi, there]), set())) def test_object_collections_mutate(self): class Foo(_base.BasicEntity): @@ -969,20 +969,20 @@ class HistoryTest(_base.ORMTest): # case 1. new object f = Foo(id=1) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [], ())) f.someattr.append(hi) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([hi], [], [])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [hi], ())) f.someattr.append(there) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([there], [hi], [])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi, there], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [hi, there], ())) f.someattr.remove(there) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi], [there])) @@ -991,7 +991,7 @@ class HistoryTest(_base.ORMTest): f.someattr.append(new) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([old, new], [hi], [there])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [hi, old, new], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [hi, old, new], ())) f.someattr.pop(0) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [old, new], [hi])) @@ -1002,19 +1002,19 @@ class HistoryTest(_base.ORMTest): collection = attributes.init_collection(attributes.instance_state(f), 'someattr') collection.append_without_event(new) attributes.instance_state(f).commit_all() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [new], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [new], ())) f.someattr.append(old) eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([old], [new], [])) attributes.instance_state(f).commit(['someattr']) - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [new, old], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [new, old], ())) f = Foo() collection = attributes.init_collection(attributes.instance_state(f), 'someattr') collection.append_without_event(new) attributes.instance_state(f).commit_all() - eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ([], [new], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'someattr'), ((), [new], ())) f.id = 1 f.someattr.remove(new) @@ -1042,19 +1042,19 @@ class HistoryTest(_base.ORMTest): f1 = Foo() b1 = Bar() - eq_(attributes.get_history(attributes.instance_state(f1), 'bars'), ([], [], [])) - eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ([], [None], [])) + eq_(attributes.get_history(attributes.instance_state(f1), 'bars'), ((), [], ())) + eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ((), [None], ())) #b1.foo = f1 f1.bars.append(b1) eq_(attributes.get_history(attributes.instance_state(f1), 'bars'), ([b1], [], [])) - eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ([f1], [], [])) + eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ([f1], (), ())) b2 = Bar() f1.bars.append(b2) eq_(attributes.get_history(attributes.instance_state(f1), 'bars'), ([b1, b2], [], [])) - eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ([f1], [], [])) - eq_(attributes.get_history(attributes.instance_state(b2), 'foo'), ([f1], [], [])) + eq_(attributes.get_history(attributes.instance_state(b1), 'foo'), ([f1], (), ())) + eq_(attributes.get_history(attributes.instance_state(b2), 'foo'), ([f1], (), ())) def test_lazy_backref_collections(self): class Foo(_base.BasicEntity): @@ -1089,7 +1089,7 @@ class HistoryTest(_base.ORMTest): lazy_load = [bar1, bar2, bar3] attributes.instance_state(f).expire_attributes(['bars']) - eq_(attributes.get_history(attributes.instance_state(f), 'bars'), ([], [bar1, bar2, bar3], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bars'), ((), [bar1, bar2, bar3], ())) def test_collections_via_lazyload(self): class Foo(_base.BasicEntity): @@ -1152,24 +1152,24 @@ class HistoryTest(_base.ORMTest): f = Foo() eq_(f.bar, "hi") - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([], ["hi"], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ((), ["hi"], ())) f = Foo() f.bar = None - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], (), ())) f = Foo() f.bar = "there" - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), (["there"], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), (["there"], (), ())) f.bar = "hi" - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), (["hi"], [], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), (["hi"], (), ())) f = Foo() eq_(f.bar, "hi") del f.bar - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([], [], ["hi"])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ((), (), ["hi"])) assert f.bar is None - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], [], ["hi"])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], (), ["hi"])) def test_scalar_object_via_lazyload(self): class Foo(_base.BasicEntity): @@ -1193,24 +1193,24 @@ class HistoryTest(_base.ORMTest): # operations f = Foo() - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([], [bar1], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ((), [bar1], ())) f = Foo() f.bar = None - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], [], [bar1])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], (), [bar1])) f = Foo() f.bar = bar2 - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([bar2], [], [bar1])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([bar2], (), [bar1])) f.bar = bar1 - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([], [bar1], [])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ((), [bar1], ())) f = Foo() eq_(f.bar, bar1) del f.bar - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], [], [bar1])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], (), [bar1])) assert f.bar is None - eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], [], [bar1])) + eq_(attributes.get_history(attributes.instance_state(f), 'bar'), ([None], (), [bar1])) if __name__ == "__main__": diff --git a/test/orm/expire.py b/test/orm/expire.py index df456fb583..3cb7101e5c 100644 --- a/test/orm/expire.py +++ b/test/orm/expire.py @@ -731,7 +731,7 @@ class PolymorphicExpireTest(_base.MappedTest): assert e1.status == 'new engineer' assert e2.status == 'old engineer' self.assert_sql_count(testing.db, go, 2) - self.assertEquals(Engineer.name.get_history(e1), (['new engineer name'], [], ['engineer1'])) + self.assertEquals(Engineer.name.get_history(e1), (['new engineer name'],(), ['engineer1'])) class RefreshTest(_fixtures.FixtureTest): diff --git a/test/orm/extendedattr.py b/test/orm/extendedattr.py index 2f4d9ab5e3..8602f26815 100644 --- a/test/orm/extendedattr.py +++ b/test/orm/extendedattr.py @@ -250,7 +250,7 @@ class UserDefinedExtensionTest(_base.ORMTest): f1 = Foo() f1.name = 'f1' - self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), (['f1'], [], [])) + self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), (['f1'], (), ())) b1 = Bar() b1.name = 'b1' @@ -260,14 +260,14 @@ class UserDefinedExtensionTest(_base.ORMTest): attributes.instance_state(f1).commit_all() attributes.instance_state(b1).commit_all() - self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), ([], ['f1'], [])) - self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'bars'), ([], [b1], [])) + self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), ((), ['f1'], ())) + self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'bars'), ((), [b1], ())) f1.name = 'f1mod' b2 = Bar() b2.name = 'b2' f1.bars.append(b2) - self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), (['f1mod'], [], ['f1'])) + self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'name'), (['f1mod'], (), ['f1'])) self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'bars'), ([b2], [b1], [])) f1.bars.remove(b1) self.assertEquals(attributes.get_history(attributes.instance_state(f1), 'bars'), ([b2], [], [b1])) -- 2.47.3