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

Commit c29c713a by Sushant Committed by Jan Aagaard Meier

Removed support for pool:false (#5914)

* removed support for pool:false

* docs updates and changelog for removal of pool:false

* fixed conn-manager test which depends upon pool:false
1 parent 18e999d7
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
- [FIXED] Add `raw` support to `instance.get()` [#5815](https://github.com/sequelize/sequelize/issues/5815) - [FIXED] Add `raw` support to `instance.get()` [#5815](https://github.com/sequelize/sequelize/issues/5815)
- [ADDED] Compare `deletedAt` against current timestamp when using paranoid [#5880](https://github.com/sequelize/sequelize/pull/5880) - [ADDED] Compare `deletedAt` against current timestamp when using paranoid [#5880](https://github.com/sequelize/sequelize/pull/5880)
- [FIXED] `BIGINT` gets truncated [#5176](https://github.com/sequelize/sequelize/issues/5176) - [FIXED] `BIGINT` gets truncated [#5176](https://github.com/sequelize/sequelize/issues/5176)
- [REMOVED] Support for `pool:false`
## BC breaks: ## BC breaks:
- `hookValidate` removed in favor of `validate` with `hooks: true | false`. `validate` returns a promise which is rejected if validation fails - `hookValidate` removed in favor of `validate` with `hooks: true | false`. `validate` returns a promise which is rejected if validation fails
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
- When `bulkCreate` is rejected because of validation failure it throws a `bluebird.AggregateError` instead of an array. This object is an array-like so length and index access will still work, but `instanceof` array will not - When `bulkCreate` is rejected because of validation failure it throws a `bluebird.AggregateError` instead of an array. This object is an array-like so length and index access will still work, but `instanceof` array will not
- `$notIn: []` will now match all rows instead of none - `$notIn: []` will now match all rows instead of none
- (MySQL) `BIGINT` now gets converted to string when number is too big - (MySQL) `BIGINT` now gets converted to string when number is too big
- Removed support for `pool:false`, if you still want to use single connection set `pool.max` to `1`
# 3.23.2 # 3.23.2
- [FIXED] Type validation now works with non-strings due to updated validator@5.0.0 [#5861](https://github.com/sequelize/sequelize/pull/5861) - [FIXED] Type validation now works with non-strings due to updated validator@5.0.0 [#5861](https://github.com/sequelize/sequelize/pull/5861)
......
...@@ -62,9 +62,9 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {}) ...@@ -62,9 +62,9 @@ var sequelize = new Sequelize('mysql://localhost:3306/database', {})
| [options.native=false] | Boolean | A flag that defines if native library shall be used or not. Currently only has an effect for postgres | | [options.native=false] | Boolean | A flag that defines if native library shall be used or not. Currently only has an effect for postgres |
| [options.replication=false] | Boolean | Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database` | | [options.replication=false] | Boolean | Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database` |
| [options.pool={}] | Object | Should sequelize use a connection pool. Default is true | | [options.pool={}] | Object | Should sequelize use a connection pool. Default is true |
| [options.pool.maxConnections] | Integer | | | [options.pool.max] | Integer | |
| [options.pool.minConnections] | Integer | | | [options.pool.min] | Integer | |
| [options.pool.maxIdleTime] | Integer | The maximum time, in milliseconds, that a connection can be idle before being released | | [options.pool.idle] | Integer | The maximum time, in milliseconds, that a connection can be idle before being released |
| [options.pool.validateConnection] | Function | A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected | | [options.pool.validateConnection] | Function | A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected |
| [options.quoteIdentifiers=true] | Boolean | Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. | | [options.quoteIdentifiers=true] | Boolean | Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. |
| [options.transactionType='DEFERRED'] | String | Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. | | [options.transactionType='DEFERRED'] | String | Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. |
...@@ -1079,4 +1079,4 @@ Note, that CLS is enabled for all sequelize instances, and all instances will sh ...@@ -1079,4 +1079,4 @@ Note, that CLS is enabled for all sequelize instances, and all instances will sh
*** ***
_This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_ _This document is automatically generated based on source code comments. Please do not edit it directly, as your changes will be ignored. Please write on <a href="irc://irc.freenode.net/#sequelizejs">IRC</a>, open an issue or a create a pull request if you feel something can be improved. For help on how to write source code documentation see [JSDoc](http://usejsdoc.org) and [dox](https://github.com/tj/dox)_
\ No newline at end of file
...@@ -106,7 +106,7 @@ var sequelize = new Sequelize('database', 'username', 'password', { ...@@ -106,7 +106,7 @@ var sequelize = new Sequelize('database', 'username', 'password', {
   
// use pooling in order to reduce db connection overload and to increase speed // use pooling in order to reduce db connection overload and to increase speed
// currently only for mysql and postgresql (since v1.5.0) // currently only for mysql and postgresql (since v1.5.0)
pool: { maxConnections: 5, maxIdleTime: 30}, pool: { max: 5, idle: 30},
   
// language is used to determine how to translate words into singular or plural form based on the [lingo project](https://github.com/visionmedia/lingo) // language is used to determine how to translate words into singular or plural form based on the [lingo project](https://github.com/visionmedia/lingo)
// options are: en [default], es // options are: en [default], es
...@@ -140,8 +140,8 @@ var sequelize = new Sequelize('database', null, null, { ...@@ -140,8 +140,8 @@ var sequelize = new Sequelize('database', null, null, {
write: { host: 'localhost', username: 'root', password: null } write: { host: 'localhost', username: 'root', password: null }
}, },
pool: { // If you want to override the options used for the read pool you can do so here pool: { // If you want to override the options used for the read pool you can do so here
maxConnections: 20, max: 20,
maxIdleTime: 30000 idle: 30000
}, },
}) })
``` ```
...@@ -152,9 +152,9 @@ Sequelize uses a pool to manage connections to your replicas. The default option ...@@ -152,9 +152,9 @@ Sequelize uses a pool to manage connections to your replicas. The default option
```js ```js
{ {
maxConnections: 10, max: 10,
minConnections: 0, min: 0,
maxIdleTime: 1000 idle: 1000
} }
``` ```
......
...@@ -21,27 +21,17 @@ ConnectionManager = function(dialect, sequelize) { ...@@ -21,27 +21,17 @@ ConnectionManager = function(dialect, sequelize) {
this.versionPromise = null; this.versionPromise = null;
this.dialectName = this.sequelize.options.dialect; this.dialectName = this.sequelize.options.dialect;
if (config.pool) { if (config.pool !== false) {
config.pool = _.clone(config.pool); // Make sure we don't modify the existing config object (user might re-use it) config.pool =_.defaults(config.pool || {}, defaultPoolingConfig, {
config.pool =_.defaults(config.pool, defaultPoolingConfig, {
validate: this.$validate.bind(this) validate: this.$validate.bind(this)
}) ; }) ;
} else { } else {
// If the user has turned off pooling we provide a 0/1 pool for backwards compat throw new Error('Support for pool:false was removed in v4.0');
config.pool = _.defaults({
max: 1,
min: 0
}, defaultPoolingConfig, {
validate: this.$validate.bind(this)
});
} }
// Map old names // Save a reference to the bound version so we can remove it with removeListener
if (config.pool.maxIdleTime) config.pool.idle = config.pool.maxIdleTime; this.onProcessExit = this.onProcessExit.bind(this);
if (config.pool.maxConnections) config.pool.max = config.pool.maxConnections;
if (config.pool.minConnections) config.pool.min = config.pool.minConnections;
this.onProcessExit = this.onProcessExit.bind(this); // Save a reference to the bound version so we can remove it with removeListener
process.on('exit', this.onProcessExit); process.on('exit', this.onProcessExit);
}; };
......
...@@ -80,9 +80,9 @@ var url = require('url') ...@@ -80,9 +80,9 @@ var url = require('url')
* @param {Boolean} [options.native=false] A flag that defines if native library shall be used or not. Currently only has an effect for postgres * @param {Boolean} [options.native=false] A flag that defines if native library shall be used or not. Currently only has an effect for postgres
* @param {Boolean} [options.replication=false] Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database` * @param {Boolean} [options.replication=false] Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database`
* @param {Object} [options.pool={}] Should sequelize use a connection pool. Default is true * @param {Object} [options.pool={}] Should sequelize use a connection pool. Default is true
* @param {Integer} [options.pool.maxConnections] * @param {Integer} [options.pool.max] Maximum number of connection in pool. Default is 5
* @param {Integer} [options.pool.minConnections] * @param {Integer} [options.pool.min] Minimum number of connection in pool. Default is 0
* @param {Integer} [options.pool.maxIdleTime] The maximum time, in milliseconds, that a connection can be idle before being released * @param {Integer} [options.pool.idle] The maximum time, in milliseconds, that a connection can be idle before being released
* @param {Function} [options.pool.validateConnection] A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected * @param {Function} [options.pool.validateConnection] A function that validates a connection. Called with client. The default function checks that client is an object, and that its state is not disconnected
* @param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them. * @param {Boolean} [options.quoteIdentifiers=true] Set to `false` to make table names and attributes case-insensitive on Postgres and skip double quoting of them.
* @param {String} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. * @param {String} [options.transactionType='DEFERRED'] Set the default transaction type. See `Sequelize.Transaction.TYPES` for possible options. Sqlite only.
......
...@@ -6,8 +6,8 @@ module.exports = { ...@@ -6,8 +6,8 @@ module.exports = {
database: process.env.SEQ_DB || 'sequelize_test', database: process.env.SEQ_DB || 'sequelize_test',
host: process.env.SEQ_HOST || '127.0.0.1', host: process.env.SEQ_HOST || '127.0.0.1',
pool: { pool: {
maxConnections: process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_POOL_IDLE || 30000 idle: process.env.SEQ_POOL_IDLE || 30000
}, },
rand: function() { rand: function() {
...@@ -25,12 +25,12 @@ module.exports = { ...@@ -25,12 +25,12 @@ module.exports = {
host: process.env.SEQ_MSSQL_HOST || process.env.SEQ_HOST || 'mssql.sequelizejs.com', host: process.env.SEQ_MSSQL_HOST || process.env.SEQ_HOST || 'mssql.sequelizejs.com',
port: process.env.SEQ_MSSQL_PORT || process.env.SEQ_PORT || 11433, port: process.env.SEQ_MSSQL_PORT || process.env.SEQ_PORT || 11433,
pool: { pool: {
maxConnections: process.env.SEQ_MSSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_MSSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MSSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 idle: process.env.SEQ_MSSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
} }
}, },
//make maxIdleTime small so that tests exit promptly //make idle time small so that tests exit promptly
mysql: { mysql: {
database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test', database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root', username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root',
...@@ -38,8 +38,8 @@ module.exports = { ...@@ -38,8 +38,8 @@ module.exports = {
host: process.env.MYSQL_PORT_3306_TCP_ADDR || process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1', host: process.env.MYSQL_PORT_3306_TCP_ADDR || process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.MYSQL_PORT_3306_TCP_PORT || process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306, port: process.env.MYSQL_PORT_3306_TCP_PORT || process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: { pool: {
maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 idle: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
} }
}, },
...@@ -53,8 +53,8 @@ module.exports = { ...@@ -53,8 +53,8 @@ module.exports = {
host: process.env.POSTGRES_PORT_5432_TCP_ADDR || process.env.SEQ_PG_HOST || process.env.SEQ_HOST || '127.0.0.1', host: process.env.POSTGRES_PORT_5432_TCP_ADDR || process.env.SEQ_PG_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.POSTGRES_PORT_5432_TCP_PORT || process.env.SEQ_PG_PORT || process.env.SEQ_PORT || 5432, port: process.env.POSTGRES_PORT_5432_TCP_PORT || process.env.SEQ_PG_PORT || process.env.SEQ_PORT || 5432,
pool: { pool: {
maxConnections: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 idle: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
} }
}, },
...@@ -65,8 +65,8 @@ module.exports = { ...@@ -65,8 +65,8 @@ module.exports = {
host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1', host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306, port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: { pool: {
maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5, max: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 idle: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
} }
} }
}; };
...@@ -34,8 +34,11 @@ if (Support.dialectIsMySQL()) { ...@@ -34,8 +34,11 @@ if (Support.dialectIsMySQL()) {
}); });
it('accepts new queries after shutting down a connection', function() { it('accepts new queries after shutting down a connection', function() {
// Create a sequelize instance with pooling disabled // Create a sequelize instance with fast disconnecting connection
var sequelize = Support.createSequelizeInstance({ pool: false }); var sequelize = Support.createSequelizeInstance({ pool: {
idle: 50,
max: 1
} });
var User = sequelize.define('User', { username: DataTypes.STRING }); var User = sequelize.define('User', { username: DataTypes.STRING });
return User.sync({force: true}).then(function() { return User.sync({force: true}).then(function() {
......
...@@ -32,13 +32,13 @@ var qq = function(str) { ...@@ -32,13 +32,13 @@ var qq = function(str) {
describe(Support.getTestDialectTeaser('Sequelize'), function() { describe(Support.getTestDialectTeaser('Sequelize'), function() {
describe('constructor', function() { describe('constructor', function() {
if (dialect !== 'sqlite') { if (dialect !== 'sqlite') {
it.skip('should work with minConnections', function() { it.skip('should work with min connections', function() {
var ConnectionManager = current.dialect.connectionManager var ConnectionManager = current.dialect.connectionManager
, connectionSpy = ConnectionManager.connect = chai.spy(ConnectionManager.connect); , connectionSpy = ConnectionManager.connect = chai.spy(ConnectionManager.connect);
Support.createSequelizeInstance({ Support.createSequelizeInstance({
pool: { pool: {
minConnections: 2 min: 2
} }
}); });
expect(connectionSpy).to.have.been.called.twice; expect(connectionSpy).to.have.been.called.twice;
......
...@@ -24,6 +24,15 @@ describe('Sequelize', function() { ...@@ -24,6 +24,15 @@ describe('Sequelize', function() {
}); });
}); });
it('should throw error if pool:false', function() {
expect(function() {
new Sequelize('localhost', 'test', 'test', {
dialect: 'mysql',
pool: false
});
}).to.throw('Support for pool:false was removed in v4.0');
});
describe('Instantiation with arguments', function() { describe('Instantiation with arguments', function() {
it('should accept four parameters (database, username, password, options)', function() { it('should accept four parameters (database, username, password, options)', function() {
var sequelize = new Sequelize('dbname', 'root', 'pass', { var sequelize = new Sequelize('dbname', 'root', 'pass', {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!