Bug #101044 Bytestrings read from a BLOB are either read as bytearray or string
Submitted: 2 Oct 2020 22:20 Modified: 5 Nov 2020 8:36
Reporter: Charmi Shah Email Updates:
Status: No Feedback Impact on me:
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.21 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[2 Oct 2020 22:20] Charmi Shah
I am reading a mysql table BLOB entry which has data stored in binary string.
This binary string is google protobuf encoded string stored in the table not within my control.

In previous version of mysql, a binary string was read as binary string causing no issue. But when I updated my mysql-connector-python to 8.0.21, sometimes data is read as bytearray and sometimes it is read as str.

This inconsistency is breaking my code. And I don't know if there are other formats in which data is read. It is cleaner if there is fixed format in which a bytestring is read preferably as bytestring!

How to repeat:
Example of a BLOB value read as a string:
Out[42]: '\n\x02\x08\x06\x12\x14\r˗\x06@\x155AP?%(֩<UL&|B'
Out[43]: str

Example of a blob value read as a bytearray:
Out[48]: bytearray(b'\n\x02\x08\x06\x12\x14\r\xa51\x15@\x15\xb10P?%\xdb\xda\xa7<U\x89\xd2wB')
Out[49]: bytearray

Suggested fix:
Provide a consistent way to read a BLOB data especially when the format is well known. Smart conversions give unexpected surprises and break codes.
[5 Oct 2020 8:36] MySQL Verification Team
Hello Charmi Shah,

Thank you for the report and feedback.
May I request you to provide a python test case(including create table and sample insert statement) which manifest the problem? Thank you.

[6 Nov 2020 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".