Fix Connection.client_flag (#266)

This commit is contained in:
Sergey Fedoseev
2018-10-23 15:04:18 +05:00
committed by INADA Naoki
parent 09018914e1
commit 9fb618806b
2 changed files with 12 additions and 1 deletions

View File

@ -2491,8 +2491,8 @@ static struct PyMemberDef _mysql_ConnectionObject_memberlist[] = {
{
"client_flag",
T_UINT,
READONLY,
offsetof(_mysql_ConnectionObject,connection.client_flag),
READONLY,
"Client flags; refer to MySQLdb.constants.CLIENT"
},
{NULL} /* Sentinel */

View File

@ -92,3 +92,14 @@ class CoreAPI(unittest.TestCase):
self.assertTrue(isinstance(self.conn.get_server_info(), str),
"Should return an str.")
def test_client_flag(self):
conn = connection_factory(
use_unicode=True,
client_flag=MySQLdb.constants.CLIENT.FOUND_ROWS)
self.assertIsInstance(conn.client_flag, (int, MySQLdb.compat.long))
self.assertTrue(conn.client_flag & MySQLdb.constants.CLIENT.FOUND_ROWS)
with self.assertRaises(TypeError if MySQLdb.compat.PY2 else AttributeError):
conn.client_flag = 0
conn.close()