Bug #73798 type_code does not compare equal
Submitted: 3 Sep 2014 20:16 Modified: 14 Oct 2014 21:07
Reporter: cruxic cruxic Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:1.2.3 OS:Any
Assigned to: CPU Architecture:Any

[3 Sep 2014 20:16] cruxic cruxic
Description:
The Database API Specification (PEP 249) says that "The type_code must compare equal to one of Type Objects defined below".  The Mysql Connector/Python does not adhere to this.  Try the following script:

How to repeat:
import mysql.connector

print 'Bug', mysql.connector.BINARY == 252

Suggested fix:
I believe the bug is in python2/mysql/connector/dbapi.py.  For example,

BINARY = _DBAPITypeObject(constants.FieldType.get_binary_types())

should probably be

BINARY = _DBAPITypeObject(*constants.FieldType.get_binary_types())
[9 Sep 2014 5:56] Peeyush Gupta
Thanks for the bug report.

Verified as described.
[14 Oct 2014 21:07] Paul DuBois
Noted in 2.0.2, 2.1.1 changelogs.

The type_code in cursor.description did not compare equal to any of
the type objects defined in mysql.connector.dbapi.