| Bug #96474 | Incorrect blob handling | ||
|---|---|---|---|
| Submitted: | 8 Aug 2019 14:06 | Modified: | 9 Aug 2019 7:24 |
| Reporter: | Marcio Reis | Email Updates: | |
| Status: | Duplicate | Impact on me: | |
| Category: | Connector for Node.js | Severity: | S1 (Critical) |
| Version: | OS: | Any | |
| Assigned to: | CPU Architecture: | Any | |
[9 Aug 2019 7:24]
Rui Quelhas
Please do not submit the same bug more than once. An existing bug report already describes this very problem. Even if you feel that your issue is somewhat different, the resolution is likely to be the same. Because of this, we hope you add your comments to the original bug instead. Thank you for your interest in MySQL.

Description: When reading a blob column, it's content is returned as UTF8 string. When inserting a blob, only string data types are allowed, therefore, binary blobs cannot be inserted correctly. How to repeat: Reading: - Create a table with a standard blob column - Insert a blob into your database (don't use the connector) - Query the blob Inserting a blob: None of the methods below work. - (Example using streams) ...sql("INSERT INTO TABLE (BLOB_COL) VALUES (?)").bind([fs.createReadStream('./img.png')]) - (Example using memory buffer) ...sql("INSERT INTO TABLE (BLOB_COL) VALUES (?)").bind([fs.readFileSync('./img.png')]) Suggested fix: - A Buffer should be returned for blobs - We should be able to insert blobs using Buffers - We should be able to insert blobs using streams