From dce8b1cde645696d8de5773f5421d2f57aab0617 Mon Sep 17 00:00:00 2001 From: Arek W Date: Fri, 28 Aug 2015 07:43:00 +0000 Subject: [PATCH] Fix noisy mysql debug output. Closes #642 --- Changelog.md | 3 +++ lib/Drivers/DML/mysql.js | 15 +++++++++++++-- package.json | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index ea20f550..563ce79a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +### v2.1.27 +- Fix noisy mysql debug output (#642) + ### v2.1.26 - Add `instance.saveAssociationsByDefault` setting - Bump node-sql-query version to v0.1.26 diff --git a/lib/Drivers/DML/mysql.js b/lib/Drivers/DML/mysql.js index 48c3155c..b898a4ad 100644 --- a/lib/Drivers/DML/mysql.js +++ b/lib/Drivers/DML/mysql.js @@ -15,6 +15,7 @@ function Driver(config, connection, opts) { if (!this.config.timezone) { this.config.timezone = "local"; } + this.query = new Query({ dialect: this.dialect, timezone: this.config.timezone }); this.reconnect(null, connection); @@ -60,9 +61,19 @@ Driver.prototype.connect = function (cb) { }; Driver.prototype.reconnect = function (cb, connection) { - this.db = (connection ? connection : mysql.createConnection(this.config.href || this.config)); + var connOpts = this.config.href || this.config; + + // Prevent noisy mysql driver output + if (typeof connOpts == 'object') { + connOpts = _.omit(connOpts, 'debug'); + } + if (typeof connOpts == 'string') { + connOpts = connOpts.replace("debug=true", "debug=false"); + } + + this.db = (connection ? connection : mysql.createConnection(connOpts)); if (this.opts.pool) { - this.db.pool = (connection ? connection : mysql.createPool(this.config.href || this.config)); + this.db.pool = (connection ? connection : mysql.createPool(connOpts)); } if (typeof cb == "function") { this.connect(cb); diff --git a/package.json b/package.json index d62232c2..1b169278 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "sqlite", "mongodb" ], - "version" : "2.1.26", + "version" : "2.1.27", "license" : "MIT", "homepage" : "http://dresende.github.io/node-orm2", "repository" : "http://github.com/dresende/node-orm2.git",