From: Mike Bayer Date: Fri, 8 Feb 2013 06:20:41 +0000 (-0500) Subject: Fixed bug whereby :meth:`.Query.yield_per` would set the execution X-Git-Tag: rel_0_8_0~23^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6195b1f755768066c78db7575275052a3e2daaa;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fixed bug whereby :meth:`.Query.yield_per` would set the execution options incorrectly, thereby breaking subsequent usage of the :meth:`.Query.execution_options` method. Courtesy Ryan Kelly. [ticket:2661] --- diff --git a/doc/build/changelog/changelog_08.rst b/doc/build/changelog/changelog_08.rst index caa4061031..d3031e5e20 100644 --- a/doc/build/changelog/changelog_08.rst +++ b/doc/build/changelog/changelog_08.rst @@ -6,6 +6,14 @@ .. changelog:: :version: 0.8.0 + .. change:: + :tags: bug, orm + :tickets: 2661 + + Fixed bug whereby :meth:`.Query.yield_per` would set the execution + options incorrectly, thereby breaking subsequent usage of the + :meth:`.Query.execution_options` method. Courtesy Ryan Kelly. + .. change:: :tags: bug, orm :tickets: 1768 diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index 02f6f3eeaf..b18e28abbf 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -712,8 +712,8 @@ class Query(object): """ self._yield_per = count - self._execution_options = self._execution_options.copy() - self._execution_options['stream_results'] = True + self._execution_options = self._execution_options.union( + {"stream_results": True}) def get(self, ident): """Return an instance based on the given primary key identifier, diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 05a13c3c15..f418d2581e 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -1784,6 +1784,17 @@ class YieldTest(QueryTest): except StopIteration: pass + def test_yield_per_and_execution_options(self): + User = self.classes.User + + sess = create_session() + q = sess.query(User).yield_per(1) + q = q.execution_options(foo='bar') + assert q._yield_per + eq_(q._execution_options, {"stream_results": True, "foo": "bar"}) + + + class HintsTest(QueryTest, AssertsCompiledSQL): def test_hints(self): User = self.classes.User