Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-red-node-mysql

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-node-mysql - npm Package Compare versions

Comparing version 0.3.0 to 1.0.0-beta

98

68-mysql.js

@@ -115,61 +115,37 @@

//console.log("query:",msg.topic);
var bind = [];
if (Array.isArray(msg.payload)) {
bind = msg.payload;
node.mydbConfig.pool.on('acquire', function(connection) {
connection.config.queryFormat = null;
});
}
else if (typeof msg.payload === 'object' && msg.payload !== null) {
bind = msg.payload;
node.mydbConfig.pool.on('acquire', function(connection) {
connection.config.queryFormat = function(query, values) {
if (!values) {
return query;
}
return query.replace(/\:(\w+)/g, function(txt, key) {
if (values.hasOwnProperty(key)) {
return this.escape(values[key]);
}
return txt;
}.bind(this));
};
});
}
node.mydbConfig.pool.query(msg.topic, bind, function(err, rows) {
node.mydbConfig.pool.getConnection(function (err, conn) {
if (err) {
status = {fill:"red",shape:"ring",text:RED._("mysql.status.error")+": "+err.code};
conn.release()
status = { fill: "red", shape: "ring", text: RED._("mysql.status.error") + ": " + err.code };
node.status(status);
node.error(err,msg);
node.error(err, msg);
if (done) { done(); }
return
}
else {
// if (rows.constructor.name === "OkPacket") {
// msg.payload = JSON.parse(JSON.stringify(rows));
// }
// else if (rows.constructor.name === "Array") {
// 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(function(v) {
// if (!Array.isArray(v)) { return v; }
// v.map(w => Object.assign({}, w))
// });
// }
// else { msg.payload = rows; }
// }
// else { msg.payload = rows; }
// }
// else { msg.payload = rows; }
msg.payload = rows;
send(msg);
status = {fill:"green",shape:"dot",text:RED._("mysql.status.ok")};
node.status(status);
var bind = [];
if (Array.isArray(msg.payload)) {
bind = msg.payload;
}
if (done) { done(); }
// if (node.mydbConfig.pool._freeConnections.indexOf(node.mydbConfig.connection) === -1) {
// node.mydbConfig.connection.release();
// }
});
else if (typeof msg.payload === 'object' && msg.payload !== null) {
bind = msg.payload;
}
conn.config.queryFormat = Array.isArray(msg.payload) ? null : customQueryFormat
conn.query(msg.topic, bind, function (err, rows) {
conn.release()
if (err) {
status = { fill: "red", shape: "ring", text: RED._("mysql.status.error") + ": " + err.code };
node.status(status);
node.error(err, msg);
}
else {
msg.payload = rows;
send(msg);
status = { fill: "green", shape: "dot", text: RED._("mysql.status.ok") };
node.status(status);
}
if (done) { done(); }
});
})
}

@@ -204,1 +180,13 @@ else {

}
function customQueryFormat(query, values) {
if (!values) {
return query;
}
return query.replace(/\:(\w+)/g, function(txt, key) {
if (values.hasOwnProperty(key)) {
return this.escape(values[key]);
}
return txt;
}.bind(this));
}
{
"name": "node-red-node-mysql",
"version": "0.3.0",
"version": "1.0.0-beta",
"description": "A Node-RED node to read and write to a MySQL database",
"dependencies": {
"mysql": "^2.18.1"
"mysql2": "^2.3.3"
},
"repository": {
"type": "git",
"url": "https://github.com/node-red/node-red-nodes/tree/master/storage/mysql"
"url": "https://github.com/node-red/node-red-nodes.git",
"directory": "tree/master/storage/mysql"
},

@@ -12,0 +13,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc