summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/base.py
diff options
context:
space:
mode:
authorAngus Lees <gus@inodes.org>2014-07-04 18:06:34 +1000
committerAngus Lees <gus@inodes.org>2014-07-10 11:25:44 +1000
commit2081502bfdf7414298d0b2c59cc74852536ce78f (patch)
tree73bd6a1dcbc4089d7a80150b1cd0ba95a4cad5e7 /lib/sqlalchemy/dialects/mysql/base.py
parente0a9b94abb92c6b62d6a6f70dec680d7ca35eed6 (diff)
downloadsqlalchemy-pr/102.tar.gz
Tell mysql that Unicode columns are unicodepr/102
Without this patch, Unicode columns get no special charset by default, and fall back to whatever the table, database, server configuration and (eventually) server hardcoded default encoding is. The hardcoded default mysql encoding is latin1. This change maps Unicode to NVARCHAR (for consistency with other sqlalchemy dialects), and UnicodeText to 'TEXT UNICODE'.
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/base.py')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 77fb34fd8..4fac5fb18 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1991,6 +1991,13 @@ class MySQLTypeCompiler(compiler.GenericTypeCompiler):
"VARCHAR requires a length on dialect %s" %
self.dialect.name)
+ def visit_unicode(self, type_):
+ return self.visit_NVARCHAR(type_)
+
+ def visit_unicode_text(self, type_):
+ spec = "TEXT(%d)" % type_.length if type_.length else "TEXT"
+ return self._extend_string(type_, {"unicode": True}, spec)
+
def visit_CHAR(self, type_):
if type_.length:
return self._extend_string(type_, {}, "CHAR(%(length)s)" %
@@ -2591,8 +2598,6 @@ class MySQLDialect(default.DefaultDialect):
raise exc.NoSuchTableError(full_name)
return row[1].strip()
- return sql
-
def _describe_table(self, connection, table, charset=None,
full_name=None):
"""Run DESCRIBE for a ``Table`` and return processed rows."""