Calling yield_per on a query followed by execution_options results in
the following error:

Traceback (most recent call last):
  File "/tmp/execution_options.py", line 18, in <module>
    query = query.execution_options(stream_results=True)
  File "<string>", line 1, in <lambda>
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line
50, in generate
    fn(self, *args[1:], **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line
1040, in execution_options
    self._execution_options = self._execution_options.union(kwargs)
AttributeError: 'dict' object has no attribute 'union'

Attached is a patch with a test case.

-Ryan Kelly

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


diff -r 53b53ad288ad lib/sqlalchemy/orm/query.py
--- a/lib/sqlalchemy/orm/query.py	Thu Feb 07 20:29:47 2013 -0500
+++ b/lib/sqlalchemy/orm/query.py	Thu Feb 07 23:05:45 2013 -0500
@@ -712,8 +712,7 @@
 
         """
         self._yield_per = count
-        self._execution_options = self._execution_options.copy()
-        self._execution_options['stream_results'] = True
+        self.execution_options(stream_results=True)
 
     def get(self, ident):
         """Return an instance based on the given primary key identifier,
diff -r 53b53ad288ad test/orm/test_query.py
--- a/test/orm/test_query.py	Thu Feb 07 20:29:47 2013 -0500
+++ b/test/orm/test_query.py	Thu Feb 07 23:05:45 2013 -0500
@@ -1784,6 +1784,13 @@
         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(stream_results=True)
+
 class HintsTest(QueryTest, AssertsCompiledSQL):
     def test_hints(self):
         User = self.classes.User

Reply via email to