summaryrefslogtreecommitdiff
path: root/test/sql/test_generative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-01-16 22:44:04 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-01-16 22:44:04 +0000
commitabccc0624228def744b0382e84f01cf95e0d3aed (patch)
treefca7eb29b90211daa699da6d0358f81243c243d9 /test/sql/test_generative.py
parent00df05061e7a0333022d02705c21270f9de4edab (diff)
downloadsqlalchemy-abccc0624228def744b0382e84f01cf95e0d3aed.tar.gz
- added "statement_options()" to Query, to so options can be
passed to the resulting statement. Currently only Select-statements have these options, and the only option used is "stream_results", and the only dialect which knows "stream_results" is psycopg2. - Query.yield_per() will set the "stream_results" statement option automatically. - Added "statement_options()" to Selects, which set statement specific options. These enable e.g. dialect specific options such as whether to enable using server side cursors, etc. - The psycopg2 now respects the statement option "stream_results". This option overrides the connection setting "server_side_cursors". If true, server side cursors will be used for the statement. If false, they will not be used, even if "server_side_cursors" is true on the connection. [ticket:1619] - added a "frozendict" from http://code.activestate.com/recipes/414283/, adding more default collections as immutable class vars on Query, Insert, Select
Diffstat (limited to 'test/sql/test_generative.py')
-rw-r--r--test/sql/test_generative.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 66c6b6c45..a9a1f59dd 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -785,6 +785,27 @@ class SelectTest(TestBase, AssertsCompiledSQL):
self.assert_compile(select_copy, "SELECT FOOBER table1.col1, table1.col2, table1.col3 FROM table1")
self.assert_compile(s, "SELECT table1.col1, table1.col2, table1.col3 FROM table1")
+ def test_statement_options(self):
+ s = select().statement_options(foo='bar')
+ s2 = s.statement_options(bar='baz')
+ s3 = s.statement_options(foo='not bar')
+ # The original select should not be modified.
+ assert s._statement_options == dict(foo='bar')
+ # s2 should have its statement_options based on s, though.
+ assert s2._statement_options == dict(foo='bar', bar='baz')
+ assert s3._statement_options == dict(foo='not bar')
+
+ def test_statement_options_in_kwargs(self):
+ s = select(statement_options=dict(foo='bar'))
+ s2 = s.statement_options(bar='baz')
+ # The original select should not be modified.
+ assert s._statement_options == dict(foo='bar')
+ # s2 should have its statement_options based on s, though.
+ assert s2._statement_options == dict(foo='bar', bar='baz')
+
+ def test_statement_options_in_text(self):
+ s = text('select 42', statement_options=dict(foo='bar'))
+ assert s._statement_options == dict(foo='bar')
class InsertTest(TestBase, AssertsCompiledSQL):
"""Tests the generative capability of Insert"""