1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

mysql - revert trying to fixup RowDataPackets introduced in 0.1.8

This commit is contained in:
Dave Conway-Jones 2021-05-10 08:53:08 +01:00
parent 2bd98c6887
commit b37d215659
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
2 changed files with 21 additions and 17 deletions

View File

@ -151,22 +151,26 @@ module.exports = function(RED) {
node.error(err,msg); node.error(err,msg);
} }
else { else {
if (rows.constructor.name === "OkPacket") { // if (rows.constructor.name === "OkPacket") {
msg.payload = JSON.parse(JSON.stringify(rows)); // msg.payload = JSON.parse(JSON.stringify(rows));
} // }
else if (rows.constructor.name === "Array") { // else if (rows.constructor.name === "Array") {
if (rows[0] && rows[0].constructor.name === "RowDataPacket") { // if (rows[0] && rows[0].constructor.name === "RowDataPacket") {
msg.payload = rows.map(v => Object.assign({}, v)); // msg.payload = rows.map(v => Object.assign({}, v));
} // }
else if (rows[0] && rows[0].constructor.name === "Array") { // else if (rows[0] && rows[0].constructor.name === "Array") {
if (rows[0][0] && rows[0][0].constructor.name === "RowDataPacket") { // if (rows[0][0] && rows[0][0].constructor.name === "RowDataPacket") {
msg.payload = rows.map(v => v.map(w => Object.assign({}, w))); // msg.payload = rows.map(function(v) {
} // if (!Array.isArray(v)) { return v; }
else { msg.payload = rows; } // v.map(w => Object.assign({}, w))
} // });
else { msg.payload = rows; } // }
} // else { msg.payload = rows; }
else { msg.payload = rows; } // }
// else { msg.payload = rows; }
// }
// else { msg.payload = rows; }
msg.payload = rows;
send(msg); send(msg);
status = {fill:"green",shape:"dot",text:"OK"}; status = {fill:"green",shape:"dot",text:"OK"};
node.status(status); node.status(status);

View File

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