From 7b55f8eba17e3d9c6c21e58386a7ac00b8b243cd Mon Sep 17 00:00:00 2001 From: Kilroy Date: Mon, 11 Dec 2017 13:37:57 +0100 Subject: [PATCH 1/3] When using use_unicode, results from tiny/medium/long blobs were not converted correctly --- MySQLdb/connections.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index c03e128d..344126a7 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -238,10 +238,8 @@ def string_decoder(s): self.set_sql_mode(sql_mode) if use_unicode: - self.converter[FIELD_TYPE.STRING].append((None, string_decoder)) - self.converter[FIELD_TYPE.VAR_STRING].append((None, string_decoder)) - self.converter[FIELD_TYPE.VARCHAR].append((None, string_decoder)) - self.converter[FIELD_TYPE.BLOB].append((None, string_decoder)) + for t in (FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING, FIELD_TYPE.VARCHAR, FIELD_TYPE.TINY_BLOB, FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.LONG_BLOB, FIELD_TYPE.BLOB): + self.converter[t].append((None, string_decoder)) self.encoders[bytes] = string_literal self.encoders[unicode] = unicode_literal From c06cf977a6608883e58f38b27d2ad055e02380bf Mon Sep 17 00:00:00 2001 From: Kilroy Date: Mon, 11 Dec 2017 14:18:43 +0100 Subject: [PATCH 2/3] Fix test for MULTIPOLYGON, result should be text, not binary --- tests/test_MySQLdb_capabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_MySQLdb_capabilities.py b/tests/test_MySQLdb_capabilities.py index f1887575..0427ed74 100644 --- a/tests/test_MySQLdb_capabilities.py +++ b/tests/test_MySQLdb_capabilities.py @@ -116,7 +116,7 @@ def test_MULTIPOLYGON(self): c.execute("SELECT id, AsText(border) FROM test_MULTIPOLYGON") row = c.fetchone() self.assertEqual(row[0], 1) - self.assertEqual(row[1], b'MULTIPOLYGON(((1 1,1 -1,-1 -1,-1 1,1 1)),((1 1,3 1,3 3,1 3,1 1)))') + self.assertEqual(row[1], 'MULTIPOLYGON(((1 1,1 -1,-1 -1,-1 1,1 1)),((1 1,3 1,3 3,1 3,1 1)))') c.execute("SELECT id, AsWKB(border) FROM test_MULTIPOLYGON") row = c.fetchone() From f7b97e7447ea5e7b32646f28fe628f2fd401cdf9 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Thu, 14 Dec 2017 17:28:40 +0900 Subject: [PATCH 3/3] wrap long line --- MySQLdb/connections.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MySQLdb/connections.py b/MySQLdb/connections.py index 344126a7..6d5f402e 100644 --- a/MySQLdb/connections.py +++ b/MySQLdb/connections.py @@ -238,7 +238,8 @@ def string_decoder(s): self.set_sql_mode(sql_mode) if use_unicode: - for t in (FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING, FIELD_TYPE.VARCHAR, FIELD_TYPE.TINY_BLOB, FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.LONG_BLOB, FIELD_TYPE.BLOB): + for t in (FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING, FIELD_TYPE.VARCHAR, FIELD_TYPE.TINY_BLOB, + FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.LONG_BLOB, FIELD_TYPE.BLOB): self.converter[t].append((None, string_decoder)) self.encoders[bytes] = string_literal