Description
Migrated issue, originally created by Anonymous
See discussion at http://groups.google.com/group/sqlalchemy/browse_thread/thread/5e51d180253cc14b
When first connecting to a database, SA issues a query to see if the DB returns unicode strings for certain data types using a CAST. Unfortunately, CAST was not added to MySQL until v 4.0.2, so SA 0.6.1 is unable to connect to older versions.
The mailing list discussion suggests 3 alternatives:
-
have cast() do nothing with the MySQL dialect if the MySQL version < 4.0.2 (is there some MySQL-specific syntax that works maybe ?)
-
have the MySQL dialect not run _check_unicode_returns if the version < 4.0.2
-
put the unicode checks in a try/except and default the returns to False if something didn't work
I've tested option 1 very briefly, and it seemed to work, but I have not tested extensively. I'm putting this ticket at low priority because I think I'm probably the only person still using such an old version, and I'm not going to have a chance to test further for a week or two at least.
The patch for turning CAST into a noop is:
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1187,6 +1187,8 @@
def visit_cast(self, cast, **kwargs):
# No cast until 4, no decimals until 5.
+ if self.dialect.server_version_info < (4, 0, 2):
+ return self.process(cast.clause)
type_ = self.process(cast.typeclause)
if type_ is None:
return self.process(cast.clause)
When I next get time to look at this, I'll add a patch for the tests to this ticket.
Thanks,
Simon
Activity
sqlalchemy-bot commentedon Jun 11, 2010
Michael Bayer (@zzzeek) wrote:
we'll likely put this into 0.6.2.
sqlalchemy-bot commentedon Jun 11, 2010
Changes by Michael Bayer (@zzzeek):
sqlalchemy-bot commentedon Jun 19, 2010
Michael Bayer (@zzzeek) wrote:
the patch plus a test is in 17073a0. Hoping this fixes the larger issue for the unicode check on connect.
sqlalchemy-bot commentedon Jun 19, 2010
Changes by Michael Bayer (@zzzeek):