summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-01-24 19:18:55 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2010-01-24 19:18:55 +0000
commit20a9cd801344c689b66ff4ee9ff9b92442878f22 (patch)
treeb5ba1449dfb4a6fe6cd1ab9697cc57034baeee2e
parentf20102829e4280cd9c35d40e32e22729ef520b0d (diff)
downloadsqlalchemy-20a9cd801344c689b66ff4ee9ff9b92442878f22.tar.gz
not ready to put execution_options in the text()/select() constructors yet
-rw-r--r--lib/sqlalchemy/orm/query.py7
-rw-r--r--lib/sqlalchemy/sql/expression.py12
-rw-r--r--test/sql/test_generative.py8
3 files changed, 13 insertions, 14 deletions
diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py
index d288e20c1..fff7fb9d9 100644
--- a/lib/sqlalchemy/orm/query.py
+++ b/lib/sqlalchemy/orm/query.py
@@ -1950,7 +1950,9 @@ class Query(object):
context.adapter = sql_util.ColumnAdapter(inner, equivs)
- statement = sql.select([inner] + context.secondary_columns, for_update=for_update, use_labels=labels, execution_options=self._execution_options)
+ statement = sql.select([inner] + context.secondary_columns, for_update=for_update, use_labels=labels)
+ if self._execution_options:
+ statement = statement.execution_options(**self._execution_options)
from_clause = inner
for eager_join in eager_joins:
@@ -1982,9 +1984,10 @@ class Query(object):
for_update=for_update,
correlate=False,
order_by=context.order_by,
- execution_options=self._execution_options,
**self._select_args
)
+ if self._execution_options:
+ statement = statement.execution_options(**self._execution_options)
if self._correlate:
statement = statement.correlate(*self._correlate)
diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py
index 26338359a..f2ad4351a 100644
--- a/lib/sqlalchemy/sql/expression.py
+++ b/lib/sqlalchemy/sql/expression.py
@@ -2224,14 +2224,12 @@ class _TextClause(_Executable, ClauseElement):
_hide_froms = []
def __init__(self, text = "", bind=None,
- bindparams=None, typemap=None, autocommit=PARSE_AUTOCOMMIT, execution_options=None):
+ bindparams=None, typemap=None,
+ autocommit=PARSE_AUTOCOMMIT):
self._bind = bind
self.bindparams = {}
self.typemap = typemap
self._autocommit = autocommit
- self._execution_options = execution_options
- if self._execution_options is None:
- self._execution_options = {}
if typemap is not None:
for key in typemap.keys():
typemap[key] = sqltypes.to_instance(typemap[key])
@@ -3193,17 +3191,13 @@ class _SelectBaseMixin(_Executable):
order_by=None,
group_by=None,
bind=None,
- autocommit=False,
- execution_options=None):
+ autocommit=False):
self.use_labels = use_labels
self.for_update = for_update
self._autocommit = autocommit
self._limit = limit
self._offset = offset
self._bind = bind
- self._execution_options = execution_options
- if self._execution_options is None:
- self._execution_options = dict()
self._order_by_clause = ClauseList(*util.to_list(order_by) or [])
self._group_by_clause = ClauseList(*util.to_list(group_by) or [])
diff --git a/test/sql/test_generative.py b/test/sql/test_generative.py
index 893f2abd7..c31a24b93 100644
--- a/test/sql/test_generative.py
+++ b/test/sql/test_generative.py
@@ -795,15 +795,17 @@ class SelectTest(TestBase, AssertsCompiledSQL):
assert s2._execution_options == dict(foo='bar', bar='baz')
assert s3._execution_options == dict(foo='not bar')
- def test_execution_options_in_kwargs(self):
+ # this feature not available yet
+ def _NOTYET_test_execution_options_in_kwargs(self):
s = select(execution_options=dict(foo='bar'))
s2 = s.execution_options(bar='baz')
# The original select should not be modified.
assert s._execution_options == dict(foo='bar')
# s2 should have its execution_options based on s, though.
assert s2._execution_options == dict(foo='bar', bar='baz')
-
- def test_execution_options_in_text(self):
+
+ # this feature not available yet
+ def _NOTYET_test_execution_options_in_text(self):
s = text('select 42', execution_options=dict(foo='bar'))
assert s._execution_options == dict(foo='bar')