question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

underscore / camelcase option should control all fields and table name generation

See original GitHub issue

It would be great if sequelize will generate PostgreSQL DDL with lower_case_underscored table name and column names. By now underscore option manage foreign keys and create_at, modifed_at fields only.

In short

CREATE TABLE IF NOT EXISTS "Male" ("CamelCase" VARCHAR(255), "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL);

should become

CREATE TABLE IF NOT EXISTS male (camel_case VARCHAR(255), "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL);

my global config is

{
    "username": "",
    "password": "",
    "database": "",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "define":{
      "paranoid":false,
      "timestamps":true,
      "freezeTableName": true,
      "underscored": true
    }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:50
  • Comments:54 (12 by maintainers)

github_iconTop GitHub Comments

93reactions
janmeiercommented, Aug 12, 2016

I don’t think this is needed - If users want underscored names, they can simply define them as such, or use the field option.

The underscored option is for controlling auto-generated column names, but when a user tells us about the column fooBar, we call it fooBar 😉

This can easily be solved with a beforeDefine hook

81reactions
maxsummerscommented, Jan 3, 2017

It took me a long time to figure out why underscored option didn’t convert my camelCase column names to under_scored ones.

I would also prefer to declare my columns as camelCased ones to be automatically converted later to underscored ones in SQL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Table Naming: Underscore vs Camelcase? namespaces ...
So mapping table columns(camelCase) and json object names(camelCase) to these properties can result in error(because mapping is case sensitive).
Read more >
Why does Oracle still not support camelcase table and column ...
Oracle's lack of support for camelcase table and column names has been a pain in my backside for far too long.
Read more >
Define Naming Rules Dialog - Documentation - Telerik
Usually this "Interpret underscore as word delimiter" option is used together with the CamelCase or PascalCase modes where each word in the name,...
Read more >
Names in the underlying database - Prisma
So if a model is remapped to a different name in the data model, the default name generation will still take the name...
Read more >
How to customize property names and values with System ...
Customize individual property names; Use camel case for all JSON property names ... To set the name of individual properties, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found