Repository navigation
Description
This feature is target the v7 release.
Issue Creation Checklist
- I understand that my issue will be automatically closed if I don't fill in the requested information
- I have read the contribution guidelines
Feature Description
"Naming Strategies" in Sequelize using the library called inflection which is still not guaranteed yet if it's result will be accurate or not. You can find some issues regarding to wrong singularization and pluralization there as it is hard-coded to get the job done https://github.com/dreamerslab/node.inflection/blob/586e605995e8e8daa6983af870f0d96e02cfac7b/lib/inflection.js#L25.
Describe the feature you'd like to see implemented
- Remove
freezeTableNameoption - Remove Sequelize "Naming Strategies", table name should remain the original to what we define in
Model.init.
class User extends Model {}
User.init({
firstName: {
type: DataTypes.STRING,
allowNull: false
},
lastName: {
type: DataTypes.STRING
}
}, {
sequelize,
modelName: 'User',
tableName: 'many_user' // Don't do any automatic table name changes
});
// the defined model is the class itself
console.log(User === sequelize.models.User); // trueIf the users do not input the tableName option, it will automically using modelName rather than leaving it null.
this.options.tableName = this.options.modelName || options.tableName;Describe why you would like this feature to be added to Sequelize
A simple reason: it can be confusing
Is this feature dialect-specific?
- No. This feature is relevant to Sequelize as a whole.
- Yes. This feature only applies to the following dialect(s):
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 will need guidance.
- No, I don't have the time, but my company or I are supporting Sequelize through donations on OpenCollective.
- No, I don't have the time, and I understand that I will need to wait until someone from the community or maintainers is interested in implementing my feature.
Indicate your interest in the addition of this feature by adding the 👍 reaction. Comments such as "+1" will be removed.
Activity
WikiRik commentedon Oct 23, 2022
There are already ways to override the singular/plural word right? I'm not sure if we should remove the automatic part of this completely and require users to input this themselves. If you think that it's not clear enough how to override it, I would suggest updating the docs about that
fzn0x commentedon Oct 23, 2022
Let me update the issue about that
[-]Remove Naming Strategies in Sequelize[/-][+]Remove Naming Strategies and `freezeTableName` option in Sequelize[/+]fzn0x commentedon Oct 23, 2022
I believe we will also remove the
freezeTableNameoption.If we keep it automically singural/plural, I'm just doubt that we have no idea in the future if the library is abandoned, or not stable for doing the pluralize or singularize job and someone figured it out.
In that case it will be hurt to find an alternative library and work on it.
fzn0x commentedon Oct 23, 2022
If the users do not input the tableName option, it will automically using modelName rather than leaving it null.
ephys commentedon Oct 24, 2022
I definitely disagree,
tableNamealready takes precedence over a pluralized version of the model if specified. Removing the auto-generation oftableNamemakes things more cumbersome for people that want to respect both SQL naming conventions (plural, snake_case) and JS naming conventions (singular, camelCase). If there is an issue here it's a docs issuefzn0x commentedon Oct 24, 2022
Thanks to make it to the point @ephys