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

Commit 39fa5979 by Mirko Jotic Committed by Jan Aagaard Meier

feat(belongsToMany): add source and target to belongs-to-many.js AssociationError (#9562)

1 parent 7525ef06
......@@ -61,7 +61,7 @@ class BelongsToMany extends Association {
super(source, target, options);
if (this.options.through === undefined || this.options.through === true || this.options.through === null) {
throw new AssociationError('belongsToMany must be given a through option, either a string or a model');
throw new AssociationError(`${source.name}.belongsToMany(${target.name}) requires through option, pass either a string or a model`);
}
if (!this.options.through.model) {
......
......@@ -107,7 +107,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
const errorFunction2 = User.belongsToMany.bind(User, Task, { through: undefined });
const errorFunction3 = User.belongsToMany.bind(User, Task, { through: null });
for (const errorFunction of [errorFunction1, errorFunction2, errorFunction3]) {
expect(errorFunction).to.throw(AssociationError, 'belongsToMany must be given a through option, either a string or a model');
expect(errorFunction).to.throw(AssociationError, `${User.name}.belongsToMany(${Task.name}) requires through option, pass either a string or a model`);
}
});
it('throws an AssociationError for a self-association defined without an alias', () => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!