-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider making allowNull: false
the new default
#14260
Labels
type: feature
For issues and PRs. For new features. Never breaking changes.
Comments
ephys
added
the
type: feature
For issues and PRs. For new features. Never breaking changes.
label
Mar 18, 2022
Would be big breaking change, but I think this is for the best. Good idea to add an option in the constructor so if people want to keep the default nullable they can |
This was referenced Apr 15, 2022
7 tasks
Hi! Is there any update on this? |
5 tasks
Hyped for this! |
Columns are nullable by default in databases. Making the opposite choice in the orm would be weird. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't think everyone is going to agree with me on this (feel free to express your opinion with the 馃憥 and 馃憤 reactions), but I think that nowadays we tend to be a lot stricter regarding what can and cannot be null.
My main reason for this change is that it would be better aligned with TypeScript. You'd only specify
allowNull
if you also made your type nullable:But I also think that in most cases, it's safer to make the application crash when null accidentally got in a field that was accidentally left nullable, than having incomplete data in the database.
To ease migration, I would also add an option in the Sequelize constructor to choose whether attributes are nullable by default .
TypeORM made this change a few years back, I think we could too.
Past issues related to this:
The text was updated successfully, but these errors were encountered: