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

Commit dd0c4c39 by Ducky Hong Committed by Sushant

fix(constructor): set username, password, database via options (#9517)

1 parent 7fff1a30
......@@ -195,14 +195,10 @@ class Sequelize {
this._setupHooks(options.hooks);
if (['', null, false].indexOf(config.password) > -1 || typeof config.password === 'undefined') {
config.password = null;
}
this.config = {
database: config.database,
username: config.username,
password: config.password,
database: config.database || this.options.database,
username: config.username || this.options.username,
password: config.password || this.options.password || null,
host: config.host || this.options.host,
port: config.port || this.options.port,
pool: this.options.pool,
......
......@@ -121,6 +121,20 @@ describe('Sequelize', () => {
expect(config.password).to.be.null;
});
it('should correctly set the username, the password and the database through options', () => {
const options = {
username: 'root',
password: 'pass',
database: 'dbname'
};
const sequelize = new Sequelize('mysql://example.com:9821', options);
const config = sequelize.config;
expect(config.username).to.equal(options.username);
expect(config.password).to.equal(options.password);
expect(config.database).to.equal(options.database);
});
it('should use the default port when no other is specified', () => {
const sequelize = new Sequelize('dbname', 'root', 'pass', {
dialect
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!