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

Commit 9bfbee6c by Dan Rumney Committed by Sushant

fix(associations): throw informational message when try to associate undefined (#8106)

1 parent 56f86182
Showing with 3 additions and 3 deletions
......@@ -9,7 +9,7 @@ const BelongsTo = require('./belongs-to');
const Mixin = {
hasMany(target, options) { // testhint options:none
if (!target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
if (!target || !target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
throw new Error(this.name + '.hasMany called with something that\'s not a subclass of Sequelize.Model');
}
......@@ -33,7 +33,7 @@ const Mixin = {
},
belongsToMany(targetModel, options) { // testhint options:none
if (!targetModel.prototype || !(targetModel.prototype instanceof this.sequelize.Model)) {
if (!targetModel || !targetModel.prototype || !(targetModel.prototype instanceof this.sequelize.Model)) {
throw new Error(this.name + '.belongsToMany called with something that\'s not a subclass of Sequelize.Model');
}
......@@ -77,7 +77,7 @@ const Mixin = {
// The logic for hasOne and belongsTo is exactly the same
function singleLinked(Type) {
return function(target, options) { // testhint options:none
if (!target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
if (!target || !target.prototype || !(target.prototype instanceof this.sequelize.Model)) {
throw new Error(this.name + '.' + Utils.lowercaseFirst(Type.toString()) + ' called with something that\'s not a subclass of Sequelize.Model');
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!