summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/mysqldb.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-03-14 14:02:44 +0100
committerMike Bayer <mike_mp@zzzcomputing.com>2020-03-21 17:03:45 -0400
commit9ec75882203b2c01aa1d362f939e21ebcd188e8d (patch)
tree343d9e368f12f839c2c737cc05d1f5e7bc615536 /lib/sqlalchemy/dialects/mysql/mysqldb.py
parent376708f4a4958bf2559c14900c52aa6fc7fd05b3 (diff)
downloadsqlalchemy-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 'lib/sqlalchemy/dialects/mysql/mysqldb.py')
-rw-r--r--lib/sqlalchemy/dialects/mysql/mysqldb.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/mysqldb.py b/lib/sqlalchemy/dialects/mysql/mysqldb.py
index 56aa991db..03c1779c3 100644
--- a/lib/sqlalchemy/dialects/mysql/mysqldb.py
+++ b/lib/sqlalchemy/dialects/mysql/mysqldb.py
@@ -154,15 +154,14 @@ class MySQLDialect_mysqldb(MySQLDialect):
# https://github.com/farcepest/MySQLdb1/commit/cd44524fef63bd3fcb71947392326e9742d520e8
# specific issue w/ the utf8mb4_bin collation and unicode returns
- has_utf8mb4_bin = self.server_version_info > (
- 5,
- ) and connection.scalar(
+ collation = connection.exec_driver_sql(
"show collation where %s = 'utf8mb4' and %s = 'utf8mb4_bin'"
% (
self.identifier_preparer.quote("Charset"),
self.identifier_preparer.quote("Collation"),
)
- )
+ ).scalar()
+ has_utf8mb4_bin = self.server_version_info > (5,) and collation
if has_utf8mb4_bin:
additional_tests = [
sql.collate(