diff options
-rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 9 | ||||
-rw-r--r-- | test/dialect/mysql/test_types.py | 11 |
2 files changed, 15 insertions, 5 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.""" diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index b7d261a88..587218266 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -238,7 +238,13 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): (mysql.ENUM, ["foo", "bar"], {'unicode':True}, '''ENUM('foo','bar') UNICODE'''), - (String, [20], {"collation": "utf8"}, 'VARCHAR(20) COLLATE utf8') + (String, [20], {"collation": "utf8"}, 'VARCHAR(20) COLLATE utf8'), + + (Unicode, [20], {}, 'NATIONAL VARCHAR(20)'), + + (UnicodeText, [], {}, 'TEXT UNICODE'), + + (UnicodeText, [20], {}, 'TEXT(20) UNICODE'), ] @@ -252,7 +258,7 @@ class TypesTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): # test that repr() copies out all arguments self.assert_compile( eval("mysql.%r" % type_inst) - if type_ is not String + if type_ not in (String, Unicode, UnicodeText) else eval("%r" % type_inst), res ) @@ -820,4 +826,3 @@ class EnumSetTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL def colspec(c): return testing.db.dialect.ddl_compiler( testing.db.dialect, None).get_column_specification(c) - |