Bug #95437 mysql-connector-python: TEXT column with only digits reads in as int
Submitted: 21 May 2019 0:26 Modified: 29 Jun 2020 22:46
Reporter: Brian Hyams Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version:8.0.16 OS:Any
Assigned to: CPU Architecture:Any
Tags: regression

[21 May 2019 0:26] Brian Hyams
Description:
When reading rows out of a cursor, a column of type TEXT that contains only digits will be read in as an integer.

Works in 8.0.15
Broken in 8.0.16

How to repeat:
1. Create a table with a column like the following:

Column description:
+-------------------------+--------------+------+-----+---------+-------+
| Field                   | Type         | Null | Key | Default | Extra |
+-------------------------+--------------+------+-----+---------+-------+
| MyTextField  | text         | YES  | MUL | NULL    |       |

2. Create python environment with mysql-connector-python v. 8.0.16.

3. Insert "3" into MyTextField (that is, a string value of "3") 

4. Run python mysql command to SELECT * using a dictionary cursor.

5. Read a row out of the cursor.

6. Check type of value in MyTextField.

Result:  type is int

Expected:  type is str

Suggested fix:
Return TEXT values as strings in python.

Confirm other TEXT columns behave similarly.
[21 May 2019 12:24] MySQL Verification Team
Hello Brian Hyams,

Thank you for the report.

regards,
Umesh
[9 Aug 2019 12:04] Brian Hyams
Has there been any progress on this?
[29 Jun 2020 22:46] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Python 8.0.21 release, and here's the proposed changelog entry from the documentation team:

Because MySQL stores TEXT types as BLOB and JSON as LONGBLOB, the TEXT and
JSON types are now converted to str and the rest of the BLOB types as
bytes. Previously, as an example, a column of type TEXT that only
contained digits was read as type=integer by Connector/Python.

Thank you for the bug report.