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
Default to snake_case for table and column names #13896
breaking changeFor issues and PRs. Changes that break compatibility and require a major version increment.type: featureDEPRECATED: replace with the "feature" issue type
Historically, Sequelize has always been using CamelCase for table names and column names. Looking into the industry "standards", it seems that the majority prefer snake_case however making queries easier to read and also allowing to remove quotes in pg for example.
Example:
JS/TS:
define('User', {
homeAddress: DataTypes.STRING
})
Database:
table name: users
columns:
id
home_address
created_at
updated_at
Reacted by Alyx, functionx.dev, Den Rupp, Martin d'Allens and Hans
My understanding is that the underscored property is for. When true, this property uses snake_case for the database columns and camelCase in the ORM. Since JS convention is camelCase I think this is the preferred method if you want to use snake_case in the DB
It is what that property is for, the idea for v7 would be to turn it on by default to follow sql conventions. Could still be turned off if you'd rather have camelCase names in the database.
Would you please specify how to turn it off? We prefer camelCase naming for db columns too.
Hope it's not per model. If so, sequelize-auto should also support this flag when generating models.
Because not all dialects follow the same conventions, I'll close in favor of #15312 which define how dialects could specify their default naming strategy
breaking changeFor issues and PRs. Changes that break compatibility and require a major version increment.type: featureDEPRECATED: replace with the "feature" issue type
Activity
ericyd commentedon Jan 5, 2022
My understanding is that the
underscoredproperty is for. Whentrue, this property uses snake_case for the database columns and camelCase in the ORM. Since JS convention is camelCase I think this is the preferred method if you want to use snake_case in the DBephys commentedon Jan 6, 2022
It is what that property is for, the idea for v7 would be to turn it on by default to follow sql conventions. Could still be turned off if you'd rather have camelCase names in the database.
mariusa commentedon Mar 3, 2022
Would you please specify how to turn it off? We prefer
camelCasenaming for db columns too.Hope it's not per model. If so,
sequelize-autoshould also support this flag when generating models.ephys commentedon Mar 3, 2022
It's just an API draft but I suppose you'd turn it off the same way you turn it on today: by setting the
underscoredoptionIt looks like
underscoredcan't be configured globally right now but it shouldn't be too hard to add a way to do it:ephys commentedon Mar 27, 2024
Because not all dialects follow the same conventions, I'll close in favor of #15312 which define how dialects could specify their default naming strategy