You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A more descriptive error when a model is being used without being initialized. #11837
Is your feature request related to a problem? Please describe.
Associating models via hasOne, belongsTo, etc. fails if the dependent model has not been initialized. This can happen if models are initialized in the wrong order, or a set has not been entirely initialized when an association method is called (as was the case in #11691).
Describe the solution you'd like
Perhaps a quick check to a flag set when a model is initialized, and it throwing a descriptive error when method is called that requires a model to be initialized first.
Why should this be in Sequelize
Noticing that various properties are undefined does not point the way to the init function, unless you're familiar with the lifecycle of a Sequelize model. A more descriptive error would save time and ultimately improve stability.
Describe alternatives/workarounds you've considered
The alternative is suffering and wasting @papb's time until you happen to notice that your setup code is running out of order.
Additional context
¯_(ツ)_/¯
Issue Template Checklist
Is this issue dialect-specific?
No. This issue is relevant to Sequelize as a whole.
Yes. This issue only applies to the following dialect(s): XXX, YYY, ZZZ
Would you be willing to resolve this issue by submitting a Pull Request?
Yes, I have the time and I know how to start.
Yes, I have the time but I don't know how to start, I would need guidance.
No, I don't have the time, although I believe I could do it if I had the time...
No, I don't have the time and I wouldn't even know how to start.
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
Activity
papb commentedon Jan 19, 2020
😆
github-actions commentedon Nov 3, 2021
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂