Skip to content

Adds support for converting column names to camelCase#4

Open
kuzzmi wants to merge 1 commit intokriasoft:mainfrom
fundof:camelCaseColumnNames
Open

Adds support for converting column names to camelCase#4
kuzzmi wants to merge 1 commit intokriasoft:mainfrom
fundof:camelCaseColumnNames

Conversation

@kuzzmi
Copy link

@kuzzmi kuzzmi commented Aug 19, 2021

This adds a support for passing column name through camelCase from lodash during file generation.

Not sure about the configuration option tho, please let me know if you have a different vision.

@bhenderson
Copy link
Contributor

I was looking for a feature like this. Although, I think the configuration should be a custom function that we can pass in. I ended up hacking it like this:

// naive way to append Table to all types generated.
const overrides = new Proxy(
  {},
  {
    get(target, name) {
      // original behavior
      const value = upperFirst(camelCase(name.replace(/[.-]/g, '_')));

      return `Table${value}`;
    },
  }
);

updateTypes(db, { overrides })

this isn't a perfect solution because overrides are used for more than just column names.

@koistya
Copy link
Member

koistya commented Aug 28, 2021

Extending overrides option to allow passing a custom function would be great!

updateTypes(db, {
  overrides: {
    "picture_url": "PictureURL",
    "*": (name, type) => type === "column" ? toCamelCase(name) : name
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants