From e47f2e03ce02f1fa1b313970291a2c024620bd73 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 23 Jun 2012 15:37:18 -0400 Subject: [PATCH] 2.5 compat --- lib/sqlalchemy/orm/loading.py | 4 +++- lib/sqlalchemy/orm/session.py | 4 ---- test/ext/test_serializer.py | 3 +++ 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index 3234d22380..8fb13b3a02 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -80,7 +80,9 @@ def instances(query, cursor, context): context.refresh_state.dict, query._only_load_props) context.progress.pop(context.refresh_state) - session._finalize_loaded(context.progress) + for state, dict_ in context.progress.items(): + state.commit_all(dict_, session.identity_map) + for ii, (dict_, attrs) in context.partials.iteritems(): ii.commit(dict_, attrs) diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 2076f23d52..1f302923d1 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -1012,10 +1012,6 @@ class Session(object): if self.autoflush and not self._flushing: self.flush() - def _finalize_loaded(self, states): - for state, dict_ in states.items(): - state.commit_all(dict_, self.identity_map) - def refresh(self, instance, attribute_names=None, lockmode=None): """Expire and refresh the attributes on the given instance. diff --git a/test/ext/test_serializer.py b/test/ext/test_serializer.py index 63a3cbe915..0496479aa0 100644 --- a/test/ext/test_serializer.py +++ b/test/ext/test_serializer.py @@ -78,6 +78,7 @@ class SerializeTest(fixtures.MappedTest): assert serializer.loads(serializer.dumps(User.name, -1), None, None) is User.name + @testing.requires.python26 # crashes in 2.5 def test_expression(self): expr = \ select([users]).select_from(users.join(addresses)).limit(5) @@ -88,6 +89,7 @@ class SerializeTest(fixtures.MappedTest): eq_(re_expr.execute().fetchall(), [(7, u'jack'), (8, u'ed'), (8, u'ed'), (8, u'ed'), (9, u'fred')]) + @testing.requires.python26 # namedtuple workaround not serializable in 2.5 @testing.skip_if(lambda: util.pypy, "pickle sometimes has " "problems here, sometimes not") def test_query(self): @@ -126,6 +128,7 @@ class SerializeTest(fixtures.MappedTest): #eq_(q2.all(), [User(name='fred')]) #eq_(list(q2.values(User.id, User.name)), [(9, u'fred')]) + @testing.requires.python26 # namedtuple workaround not serializable in 2.5 @testing.exclude('sqlite', '<=', (3, 5, 9), 'id comparison failing on the buildbot') def test_aliases(self): -- 2.47.3