Fix mysql multiple return queries type

to close #797
This commit is contained in:
Dave Conway-Jones 2021-04-23 22:23:16 +01:00
parent 246463752e
commit fdfdbb17b7
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 11 additions and 2 deletions

View File

@ -155,7 +155,16 @@ module.exports = function(RED) {
msg.payload = JSON.parse(JSON.stringify(rows));
}
else if (rows.constructor.name === "Array") {
msg.payload = rows.map(v => Object.assign({}, v));
if (rows[0] && rows[0].constructor.name === "RowDataPacket") {
msg.payload = rows.map(v => Object.assign({}, v));
}
else if (rows[0] && rows[0].constructor.name === "Array") {
if (rows[0][0] && rows[0][0].constructor.name === "RowDataPacket") {
msg.payload = rows.map(v => v.map(w => Object.assign({}, w)));
}
else { msg.payload = rows; }
}
else { msg.payload = rows; }
}
else { msg.payload = rows; }
send(msg);

View File

@ -1,6 +1,6 @@
{
"name": "node-red-node-mysql",
"version": "0.1.7",
"version": "0.1.8",
"description": "A Node-RED node to read and write to a MySQL database",
"dependencies": {
"mysql": "^2.18.1"