Skip to content

Commit dce8b1c

Browse files
committed
Fix noisy mysql debug output. Closes #642
1 parent 0491458 commit dce8b1c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v2.1.27
2+
- Fix noisy mysql debug output (#642)
3+
14
### v2.1.26
25
- Add `instance.saveAssociationsByDefault` setting
36
- Bump node-sql-query version to v0.1.26

lib/Drivers/DML/mysql.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ function Driver(config, connection, opts) {
1515
if (!this.config.timezone) {
1616
this.config.timezone = "local";
1717
}
18+
1819
this.query = new Query({ dialect: this.dialect, timezone: this.config.timezone });
1920

2021
this.reconnect(null, connection);
@@ -60,9 +61,19 @@ Driver.prototype.connect = function (cb) {
6061
};
6162

6263
Driver.prototype.reconnect = function (cb, connection) {
63-
this.db = (connection ? connection : mysql.createConnection(this.config.href || this.config));
64+
var connOpts = this.config.href || this.config;
65+
66+
// Prevent noisy mysql driver output
67+
if (typeof connOpts == 'object') {
68+
connOpts = _.omit(connOpts, 'debug');
69+
}
70+
if (typeof connOpts == 'string') {
71+
connOpts = connOpts.replace("debug=true", "debug=false");
72+
}
73+
74+
this.db = (connection ? connection : mysql.createConnection(connOpts));
6475
if (this.opts.pool) {
65-
this.db.pool = (connection ? connection : mysql.createPool(this.config.href || this.config));
76+
this.db.pool = (connection ? connection : mysql.createPool(connOpts));
6677
}
6778
if (typeof cb == "function") {
6879
this.connect(cb);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"sqlite",
1313
"mongodb"
1414
],
15-
"version" : "2.1.26",
15+
"version" : "2.1.27",
1616
"license" : "MIT",
1717
"homepage" : "http://dresende.github.io/node-orm2",
1818
"repository" : "http://github.com/dresende/node-orm2.git",

0 commit comments

Comments
 (0)