-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type
Description
What are you doing?
When I have a model that defines a property whose name matches one of the mixin names that would get generated when I add an association to the model, the model definition and association blows up.
module.exports = (sequelize, DataTypes) => {
const Company = sequelize.define("company", {
hasLocations: {
type: DataTypes.BOOLEAN
}
})
Company.associate = models => {
Company.Locations = Company.hasMany(models.location)
}
return Company
}What do you expect to happen?
I don't want it to blow up and instead want to skip the hasLocations() method mixin definition because it conflicts with the hasLocations prop
What is actually happening?
I get the following error
TypeError: Cannot read property 'hasLocations' of undefined
at Model.get (<project-root>/node_modules/sequelize/lib/model.js:3305:29)
at Model.funcs.(anonymous function) (<project-root>/node_modules/sequelize/lib/model.js:1022:25)
at Object.mixinMethods (<project-root>/node_modules/sequelize/lib/associations/helpers.js:58:13)
at HasMany.mixin (<project-root>/node_modules/sequelize/lib/associations/has-many.js:155:13)
at Function.hasMany (<project-root>/node_modules/sequelize/lib/associations/mixin.js:34:17)Sequelize version: 5.0.0-beta.12
Tested with latest release: Yes (If yes, specify that version)
Metadata
Metadata
Assignees
Labels
type: bugDEPRECATED: replace with the "bug" issue typeDEPRECATED: replace with the "bug" issue type