|
44 | 44 | import traceback
|
45 | 45 | import time
|
46 | 46 | import unittest
|
| 47 | +import pickle |
47 | 48 |
|
48 | 49 | import tests
|
49 | 50 | from tests import foreach_cnx, cnx_config
|
@@ -4305,3 +4306,39 @@ def test_cext_verify_server_certifcate(self):
|
4305 | 4306 | mysql.connector.connect, **self.config)
|
4306 | 4307 | self.config['ssl_verify_cert'] = False
|
4307 | 4308 | mysql.connector.connect(**self.config)
|
| 4309 | + |
| 4310 | + |
| 4311 | +class BugOra25589496(tests.MySQLConnectorTests): |
| 4312 | + """BUG#25589496: COMMITS RELATED TO "BUG22529828" BROKE BINARY DATA |
| 4313 | + HANDLING FOR PYTHON 2.7 |
| 4314 | + """ |
| 4315 | + def setUp(self): |
| 4316 | + config = tests.get_mysql_config() |
| 4317 | + self.cnx = connection.MySQLConnection(**config) |
| 4318 | + self.tbl = "Bug25589496" |
| 4319 | + self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl)) |
| 4320 | + |
| 4321 | + def tearDown(self): |
| 4322 | + self.cnx.cmd_query("DROP TABLE IF EXISTS {0}".format(self.tbl)) |
| 4323 | + self.cnx.close() |
| 4324 | + |
| 4325 | + def test_insert_binary(self): |
| 4326 | + table = """ |
| 4327 | + CREATE TABLE {0} ( |
| 4328 | + `id` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, |
| 4329 | + `section` VARCHAR(50) NOT NULL, |
| 4330 | + `pickled` LONGBLOB NOT NULL |
| 4331 | + ) |
| 4332 | + """.format(self.tbl) |
| 4333 | + cursor = self.cnx.cursor() |
| 4334 | + cursor.execute(table) |
| 4335 | + |
| 4336 | + pickled = pickle.dumps({'a': 'b'}, pickle.HIGHEST_PROTOCOL) |
| 4337 | + add_row_q = "INSERT INTO {0} (section, pickled) " \ |
| 4338 | + "VALUES (%(section)s, %(pickled)s)".format(self.tbl) |
| 4339 | + |
| 4340 | + new_row = cursor.execute(add_row_q, {'section': 'foo', |
| 4341 | + 'pickled': pickled}) |
| 4342 | + self.cnx.commit() |
| 4343 | + self.assertEqual(1, cursor.lastrowid) |
| 4344 | + cursor.close() |
0 commit comments