diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2020-03-14 14:02:44 +0100 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-03-21 17:03:45 -0400 |
| commit | 9ec75882203b2c01aa1d362f939e21ebcd188e8d (patch) | |
| tree | 343d9e368f12f839c2c737cc05d1f5e7bc615536 /test/sql/test_quote.py | |
| parent | 376708f4a4958bf2559c14900c52aa6fc7fd05b3 (diff) | |
| download | sqlalchemy-9ec75882203b2c01aa1d362f939e21ebcd188e8d.tar.gz | |
Deprecate plain string in execute and introduce `exec_driver_sql`
Execution of literal sql string is deprecated in the
:meth:`.Connection.execute` and a warning is raised when used stating
that it will be coerced to :func:`.text` in a future release.
To execute a raw sql string the new connection method
:meth:`.Connection.exec_driver_sql` was added, that will retain the previous
behavior, passing the string to the DBAPI driver unchanged.
Usage of scalar or tuple positional parameters in :meth:`.Connection.execute`
is also deprecated.
Fixes: #4848
Fixes: #5178
Change-Id: I2830181054327996d594f7f0d59c157d477c3aa9
Diffstat (limited to 'test/sql/test_quote.py')
| -rw-r--r-- | test/sql/test_quote.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/test/sql/test_quote.py b/test/sql/test_quote.py index aba6a0204..627626994 100644 --- a/test/sql/test_quote.py +++ b/test/sql/test_quote.py @@ -90,19 +90,23 @@ class QuoteExecTest(fixtures.TestBase): @testing.provide_metadata def test_has_table_case_sensitive(self): preparer = testing.db.dialect.identifier_preparer - if testing.db.dialect.requires_name_normalize: - testing.db.execute("CREATE TABLE TAB1 (id INTEGER)") - else: - testing.db.execute("CREATE TABLE tab1 (id INTEGER)") - testing.db.execute( - "CREATE TABLE %s (id INTEGER)" % preparer.quote_identifier("tab2") - ) - testing.db.execute( - "CREATE TABLE %s (id INTEGER)" % preparer.quote_identifier("TAB3") - ) - testing.db.execute( - "CREATE TABLE %s (id INTEGER)" % preparer.quote_identifier("TAB4") - ) + with testing.db.connect() as conn: + if conn.dialect.requires_name_normalize: + conn.exec_driver_sql("CREATE TABLE TAB1 (id INTEGER)") + else: + conn.exec_driver_sql("CREATE TABLE tab1 (id INTEGER)") + conn.exec_driver_sql( + "CREATE TABLE %s (id INTEGER)" + % preparer.quote_identifier("tab2") + ) + conn.exec_driver_sql( + "CREATE TABLE %s (id INTEGER)" + % preparer.quote_identifier("TAB3") + ) + conn.exec_driver_sql( + "CREATE TABLE %s (id INTEGER)" + % preparer.quote_identifier("TAB4") + ) t1 = Table( "tab1", self.metadata, Column("id", Integer, primary_key=True) |
