Bug #97723 Parsing TEXT field returns wrong data type in python
Submitted: 20 Nov 2019 22:18 Modified: 31 Jan 22:00
Reporter: Nicholas Lee-Hone Email Updates:
Status: Verified Impact on me:
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.16, 8.0.18 OS:Any
Assigned to: CPU Architecture:Any

[20 Nov 2019 22:18] Nicholas Lee-Hone
The following diff going from 8.0.15 to 8.0.16 caused an issue where TEXT fields get parsed as either float or int data types if the TEXT contains only a number.

-        if dsc is not None:
-            if dsc[7] & FieldFlag.BINARY:
-                if PY2:
-                    return value
-                elif isinstance(value, str):
-                    return bytes(value, self.charset)
-                return bytes(value)
-        return self._STRING_to_python(value, dsc)
-    _LONG_BLOB_to_python = _JSON_to_python
+        if not value:
+            # This is an empty BLOB
+            return ""
+        # JSON Values are stored in LONG BLOB, but the blob values recived
+        # from the server are not dilutable, check for JSON values.
+        return self._JSON_to_python(value, dsc)
+    _LONG_BLOB_to_python = _BLOB_to_python

def _JSON_to_python(self, value, dsc=None):  # pylint: disable=C0103
        """Returns JSON column type as python type
        Returns JSON column type as python type.
            num = float(value)
            if num.is_integer():
                return int(value)
            return num
        except ValueError:

How to repeat:
Save an integer or a float to a TEXT field.

Query the field and check the data type.

Suggested fix:
Remove the try block where float/int coercion is attempted.


Process TEXT blocks and BLOB blocks seperately.
[22 Nov 2019 4:37] MySQL Verification Team
Hello Nicholas Lee-Hone,

Thank you for the report.

[31 Jan 22:00] Nicholas Lee-Hone
Can we get an update on this issue? This is blocking us from upgrading to the latest version of mysql connector.