Bug #96480 The API used to insert/update blobs can be improved
Submitted: 8 Aug 2019 20:54 Modified: 27 Sep 2019 21:57
Reporter: Marcio Reis Email Updates:
Status: Closed Impact on me:
None 
Category:Connector for Node.js Severity:S4 (Feature request)
Version:8.0.17 OS:Any
Assigned to: Rui Quelhas CPU Architecture:Any

[8 Aug 2019 20:54] Marcio Reis
Description:
When inserting blobs we have to translate it into hex string. It would be great to have the API to handle a Buffer and do the grunt work for us. 

How to repeat:
Current:
var myBlob = fs.readFileSync('./file.png');
session.sql(`INSERT INTO TABLE (BLOB_COL) VALUES (X'${myBlob.toString('hex')}))

Suggested fix:
Suggestion:
var myBlob = fs.readFileSync('./file.png');
session.sql("INSERT INTO TABLE (BLOB_COL) VALUES (?)').bind([myBlob])

Or even better:
session.sql("INSERT INTO TABLE (BLOB_COL) VALUES (?)', [myBlob])
[27 Sep 2019 21:44] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Node.js 8.0.18 release, and here's the changelog entry:

Added support for assigning Node.js Buffer values to expression or SQL
query placeholders.

Thank you for the bug report.