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

Commit 9e709cee by Jan Aagaard Meier

Properly set default port

1 parent 304fab8a
...@@ -13,7 +13,6 @@ module.exports = (function() { ...@@ -13,7 +13,6 @@ module.exports = (function() {
this.pooling = (!!this.config.pool && (this.config.pool.maxConnections > 0)) this.pooling = (!!this.config.pool && (this.config.pool.maxConnections > 0))
this.pg = this.config.native ? require(pgModule).native : require(pgModule) this.pg = this.config.native ? require(pgModule).native : require(pgModule)
this.poolIdentifier = null this.poolIdentifier = null
// Better support for BigInts // Better support for BigInts
// https://github.com/brianc/node-postgres/issues/166#issuecomment-9514935 // https://github.com/brianc/node-postgres/issues/166#issuecomment-9514935
this.pg.types.setTypeParser(20, String); this.pg.types.setTypeParser(20, String);
......
...@@ -20,7 +20,7 @@ module.exports = (function() { ...@@ -20,7 +20,7 @@ module.exports = (function() {
@param {String} [options.dialect='mysql'] The dialect of the relational database. @param {String} [options.dialect='mysql'] The dialect of the relational database.
@param {String} [options.dialectModulePath=null] If specified, load the dialect library from this path. @param {String} [options.dialectModulePath=null] If specified, load the dialect library from this path.
@param {String} [options.host='localhost'] The host of the relational database. @param {String} [options.host='localhost'] The host of the relational database.
@param {Integer} [options.port=3306] The port of the relational database. @param {Integer} [options.port=] The port of the relational database.
@param {String} [options.protocol='tcp'] The protocol of the relational database. @param {String} [options.protocol='tcp'] The protocol of the relational database.
@param {Object} [options.define={}] Options, which shall be default for every model definition. @param {Object} [options.define={}] Options, which shall be default for every model definition.
@param {Object} [options.query={}] I have absolutely no idea. @param {Object} [options.query={}] I have absolutely no idea.
...@@ -75,7 +75,6 @@ module.exports = (function() { ...@@ -75,7 +75,6 @@ module.exports = (function() {
dialect: 'mysql', dialect: 'mysql',
dialectModulePath: null, dialectModulePath: null,
host: 'localhost', host: 'localhost',
port: 3306,
protocol: 'tcp', protocol: 'tcp',
define: {}, define: {},
query: {}, query: {},
......
...@@ -70,13 +70,23 @@ describe(Support.getTestDialectTeaser("Configuration"), function() { ...@@ -70,13 +70,23 @@ describe(Support.getTestDialectTeaser("Configuration"), function() {
done() done()
}) })
it('should use the default port when no other is specified', function(done) { it('should use the default port when no other is specified', function() {
var sequelize = new Sequelize('mysql://example.com/dbname') var sequelize = new Sequelize('dbname', 'root', 'pass', {
var config = sequelize.config dialect: dialect
})
, config = sequelize.connectorManager.config
, port
if (Support.dialectIsMySQL()) {
port = 3306
} else if (dialect === "postgres" || dialect === "postgres-native") {
port = 5432
} else {
// sqlite has no concept of ports when connecting
return
}
// The default port should be set expect(config.port).to.equal(port)
expect(config.port).to.equal(3306)
done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!