From df15546cb8903e0eef0182faa0eda1691bf6bac8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 13 Feb 2012 20:07:44 -0500 Subject: - [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] --- test/engine/test_execute.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/engine') diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index f3206e9cc..dc3e46aab 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -41,6 +41,16 @@ class ExecuteTest(fixtures.TestBase): def teardown_class(cls): metadata.drop_all() + def test_no_params_option(self): + stmt = "SELECT '%'" + if testing.against('oracle'): + stmt += " FROM DUAL" + conn = testing.db.connect() + result = conn.\ + execution_options(no_parameters=True).\ + scalar(stmt) + eq_(result, '%') + @testing.fails_on_everything_except('firebird', 'maxdb', 'sqlite', '+pyodbc', '+mxodbc', '+zxjdbc', 'mysql+oursql', -- cgit v1.2.1