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

Commit 669f09fd by Sushant Committed by GitHub

fix(sequelize/sync): show database name and match condition when sync is rejected (#8482)

1 parent 44ad6bab
......@@ -670,14 +670,13 @@ class Sequelize {
* @return {Promise}
*/
sync(options) {
options = _.clone(options) || {};
options.hooks = options.hooks === undefined ? true : !!options.hooks;
options = _.defaults(options, this.options.sync, this.options);
if (options.match) {
if (!options.match.test(this.config.database)) {
return Promise.reject(new Error('Database does not match sync match parameter'));
return Promise.reject(new Error(`Database "${this.config.database}" does not match sync match parameter "${options.match}"`));
}
}
......
......@@ -987,6 +987,18 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
});
});
it('fails with incorrect match condition', function() {
const sequelize = new Sequelize('cyber_bird', 'user', 'pass', {
dialect: this.sequelize.options.dialect
});
sequelize.define('Project', {title: Sequelize.STRING});
sequelize.define('Task', {title: Sequelize.STRING});
return expect(sequelize.sync({force: true, match: /$phoenix/}))
.to.be.rejectedWith('Database "cyber_bird" does not match sync match parameter "/$phoenix/"');
});
if (dialect !== 'sqlite') {
it('fails with incorrect database credentials (1)', function() {
this.sequelizeWithInvalidCredentials = new Sequelize('omg', 'bar', null, _.omit(this.sequelize.options, ['host']));
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!