Skip to content

Commit

Permalink
Fix noisy mysql debug output. Closes #642
Browse files Browse the repository at this point in the history
  • Loading branch information
dxg committed Aug 28, 2015
1 parent 0491458 commit dce8b1c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 13 additions & 2 deletions lib/Drivers/DML/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dce8b1c

Please sign in to comment.