Skip to content

Commit 9fb6188

Browse files
sir-sigurdmethane
authored andcommitted
Fix Connection.client_flag (PyMySQL#266)
1 parent 0901891 commit 9fb6188

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

_mysql.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2491,8 +2491,8 @@ static struct PyMemberDef _mysql_ConnectionObject_memberlist[] = {
24912491
{
24922492
"client_flag",
24932493
T_UINT,
2494-
READONLY,
24952494
offsetof(_mysql_ConnectionObject,connection.client_flag),
2495+
READONLY,
24962496
"Client flags; refer to MySQLdb.constants.CLIENT"
24972497
},
24982498
{NULL} /* Sentinel */

tests/test_MySQLdb_nonstandard.py

+11
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,14 @@ def test_server_info(self):
9292
self.assertTrue(isinstance(self.conn.get_server_info(), str),
9393
"Should return an str.")
9494

95+
def test_client_flag(self):
96+
conn = connection_factory(
97+
use_unicode=True,
98+
client_flag=MySQLdb.constants.CLIENT.FOUND_ROWS)
99+
100+
self.assertIsInstance(conn.client_flag, (int, MySQLdb.compat.long))
101+
self.assertTrue(conn.client_flag & MySQLdb.constants.CLIENT.FOUND_ROWS)
102+
with self.assertRaises(TypeError if MySQLdb.compat.PY2 else AttributeError):
103+
conn.client_flag = 0
104+
105+
conn.close()

0 commit comments

Comments
 (0)