]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
map MySQL encodings to python encodings fixes #2771
authorThomas Grainger <tom@yplanapp.com>
Wed, 18 Mar 2015 11:22:25 +0000 (11:22 +0000)
committerThomas Grainger <tom@yplanapp.com>
Wed, 18 Mar 2015 11:45:24 +0000 (11:45 +0000)
lib/sqlalchemy/dialects/mysql/base.py

index b8392bd4e1c6e53e814ce2fb406654a1d983b9c8..7881c47a898b04436d5a7e8353389cdc1c292526 100644 (file)
@@ -3296,9 +3296,17 @@ class _DecodingRowProxy(object):
     # sets.Set(['value']) (seriously) but thankfully that doesn't
     # seem to come up in DDL queries.
 
+    _encoding_compat = {
+        'koi8r': 'koi8_r',
+        'koi8u': 'koi8_u',
+        'utf16': 'utf-16-be',  # MySQL's uft16 is always bigendian
+        'utf8mb4': 'utf8',  # real utf8
+        'eucjpms': 'ujis',
+    }
+
     def __init__(self, rowproxy, charset):
         self.rowproxy = rowproxy
-        self.charset = charset
+        self.charset = self._encoding_compat.get(charset, charset)
 
     def __getitem__(self, index):
         item = self.rowproxy[index]