From abccc0624228def744b0382e84f01cf95e0d3aed Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 16 Jan 2010 22:44:04 +0000 Subject: - 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 --- lib/sqlalchemy/sql/expression.py | 65 ++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 22 deletions(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 742746cbe..2dc13ee82 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2178,8 +2178,13 @@ class _TypeClause(ClauseElement): def __init__(self, type): self.type = type +class _Executable(object): + """Mark a ClauseElement as supporting execution.""" -class _TextClause(ClauseElement): + supports_execution = True + _statement_options = util.frozendict() + +class _TextClause(_Executable, ClauseElement): """Represent a literal SQL text fragment. Public constructor is the :func:`text()` function. @@ -2189,7 +2194,6 @@ class _TextClause(ClauseElement): __visit_name__ = 'textclause' _bind_params_regex = re.compile(r'(?