不要怂,就是干,撸起袖子干!

Commit 06aa7aae by Willyham

Add default value. Deep clone config

1 parent b5c6c249
...@@ -65,7 +65,7 @@ ConnectionManager.prototype.close = function () { ...@@ -65,7 +65,7 @@ ConnectionManager.prototype.close = function () {
// If he does this, generic-pool will try to call connect before the dialect-specific connection manager has been correctly set up // If he does this, generic-pool will try to call connect before the dialect-specific connection manager has been correctly set up
ConnectionManager.prototype.initPools = function () { ConnectionManager.prototype.initPools = function () {
var self = this var self = this
, config = this.config; , config = _.cloneDeep(this.config);
if (!config.replication) { if (!config.replication) {
this.pool = Pooling.Pool({ this.pool = Pooling.Pool({
...@@ -92,12 +92,6 @@ ConnectionManager.prototype.initPools = function () { ...@@ -92,12 +92,6 @@ ConnectionManager.prototype.initPools = function () {
config.replication.read = [config.replication.read]; config.replication.read = [config.replication.read];
} }
// Make sure we don't modify the existing config object (user might re-use it)
config.replication.write = _.clone(config.replication.write);
config.replication.read = config.replication.read.map(function (read) {
return _.clone(read);
});
// Map main connection config // Map main connection config
config.replication.write = _.defaults(config.replication.write, { config.replication.write = _.defaults(config.replication.write, {
host: config.host, host: config.host,
......
...@@ -654,7 +654,7 @@ module.exports = (function() { ...@@ -654,7 +654,7 @@ module.exports = (function() {
* @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified * @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified
* @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row * @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row
* @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL. * @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL.
* @param {Boolean} [options.forceWrite] Force the query to use the write pool, regardless of the query type. * @param {Boolean} [options.forceWrite=false] Force the query to use the write pool, regardless of the query type.
* *
* @return {Promise} * @return {Promise}
* *
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!