summaryrefslogtreecommitdiff
path: root/test/dialect/mysql.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/dialect/mysql.py')
-rw-r--r--test/dialect/mysql.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/dialect/mysql.py b/test/dialect/mysql.py
index e1bd47d29..00478908e 100644
--- a/test/dialect/mysql.py
+++ b/test/dialect/mysql.py
@@ -927,6 +927,49 @@ class SQLTest(TestBase, AssertsCompiledSQL):
self.assert_compile(cast(t.c.col, type_), expected)
+class ExecutionTest(TestBase):
+ """Various MySQL execution special cases."""
+
+ __only_on__ = 'mysql'
+
+ def test_charset_caching(self):
+ engine = engines.testing_engine()
+
+ cx = engine.connect()
+ meta = MetaData()
+
+ assert ('mysql', 'charset') not in cx.info
+ assert ('mysql', 'force_charset') not in cx.info
+
+ cx.execute(text("SELECT 1")).fetchall()
+ assert ('mysql', 'charset') not in cx.info
+
+ meta.reflect(cx)
+ assert ('mysql', 'charset') in cx.info
+
+ cx.execute(text("SET @squiznart=123"))
+ assert ('mysql', 'charset') in cx.info
+
+ # the charset invalidation is very conservative
+ cx.execute(text("SET TIMESTAMP = DEFAULT"))
+ assert ('mysql', 'charset') not in cx.info
+
+ cx.info[('mysql', 'force_charset')] = 'latin1'
+
+ assert engine.dialect._detect_charset(cx) == 'latin1'
+ assert cx.info[('mysql', 'charset')] == 'latin1'
+
+ del cx.info[('mysql', 'force_charset')]
+ del cx.info[('mysql', 'charset')]
+
+ meta.reflect(cx)
+ assert ('mysql', 'charset') in cx.info
+
+ # String execution doesn't go through the detector.
+ cx.execute("SET TIMESTAMP = DEFAULT")
+ assert ('mysql', 'charset') in cx.info
+
+
def colspec(c):
return testing.db.dialect.schemagenerator(testing.db.dialect,
testing.db, None, None).get_column_specification(c)