diff options
author | Jason Kirtland <jek@discorporate.us> | 2008-04-02 11:39:26 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2008-04-02 11:39:26 +0000 |
commit | f12969a4d8dd8a4f91a9da4cc9d855457a5a0060 (patch) | |
tree | 274125cdcd73dbcea79575b7a82810032ae0be36 /test/dialect/mysql.py | |
parent | a0000075437370ae23d0db48c706a4237f4e43f3 (diff) | |
download | sqlalchemy-f12969a4d8dd8a4f91a9da4cc9d855457a5a0060.tar.gz |
- Revamped the Connection memoize decorator a bit, moved to engine
- MySQL character set caching is more aggressive but will invalidate the cache if a SET is issued.
- MySQL connection memos are namespaced: info[('mysql', 'server_variable')]
Diffstat (limited to 'test/dialect/mysql.py')
-rw-r--r-- | test/dialect/mysql.py | 43 |
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) |