diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-13 20:07:44 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-13 20:07:44 -0500 |
commit | df15546cb8903e0eef0182faa0eda1691bf6bac8 (patch) | |
tree | e04c2e4d7d0156a176cd5d950792b1a3281a674d /lib/sqlalchemy/engine/default.py | |
parent | f37aa86df8fa885a5d098930c8a444b96f374f60 (diff) | |
download | sqlalchemy-df15546cb8903e0eef0182faa0eda1691bf6bac8.tar.gz |
- [feature] Added "no_parameters=True" execution
option for connections. If no parameters
are present, will pass the statement
as cursor.execute(statement), thereby invoking
the DBAPIs behavior when no parameter collection
is present; for psycopg2 and mysql-python, this
means not interpreting % signs in the string.
This only occurs with this option, and not
just if the param list is blank, as otherwise
this would produce inconsistent behavior
of SQL expressions that normally escape percent
signs (and while compiling, can't know ahead of
time if parameters will be present in
some cases). [ticket:2407]
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
-rw-r--r-- | lib/sqlalchemy/engine/default.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index a1e5a5799..5c2d98146 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -334,6 +334,9 @@ class DefaultDialect(base.Dialect): def do_execute(self, cursor, statement, parameters, context=None): cursor.execute(statement, parameters) + def do_execute_no_params(self, cursor, statement, context=None): + cursor.execute(statement) + def is_disconnect(self, e, connection, cursor): return False @@ -538,6 +541,10 @@ class DefaultExecutionContext(base.ExecutionContext): return self @util.memoized_property + def no_parameters(self): + return self.execution_options.get("no_parameters", False) + + @util.memoized_property def is_crud(self): return self.isinsert or self.isupdate or self.isdelete |