]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixed bug whereby :meth:`.Query.yield_per` would set the execution
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 8 Feb 2013 06:20:41 +0000 (01:20 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 8 Feb 2013 06:20:41 +0000 (01:20 -0500)
options incorrectly, thereby breaking subsequent usage of the
:meth:`.Query.execution_options` method.  Courtesy Ryan Kelly.
[ticket:2661]

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/orm/query.py
test/orm/test_query.py

index caa40610314ce24bd7b116bcbbe8aac0cdf6a454..d3031e5e207273e88cd578375c162c2eb5688b4a 100644 (file)
@@ -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
index 02f6f3eeaf3b80ae00e4021c728f457c459dc855..b18e28abbfa7c3fe342f234502152fd897b3248b 100644 (file)
@@ -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,
index 05a13c3c15d2c6557c4e400ba80c336fc092beae..f418d2581e90fabf269e789c2b6d4f7fedf5b8f3 100644 (file)
@@ -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