Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for different field name casing #1254

Closed
fieryorc opened this issue Nov 8, 2016 · 3 comments
Closed

Add support for different field name casing #1254

fieryorc opened this issue Nov 8, 2016 · 3 comments

Comments

@fieryorc
Copy link

fieryorc commented Nov 8, 2016

I use existing DB that uses camel case for field names and snake case for table names. Gorm seems to have hardcoded ToDBName() function that is not customizable.

our table looks like this:

product_skus {
skuId string
}

@jinzhu
Copy link
Member

jinzhu commented Nov 10, 2016

@jinzhu jinzhu closed this as completed Nov 10, 2016
@fieryorc
Copy link
Author

fieryorc commented Nov 10, 2016

@jinzhu
Here are the problems with the current approach:

  1. The relationships don't still pick up the metadata for column names (many2many doesn't work).. Check my stackoverflow question here. http://stackoverflow.com/questions/40094666/gorm-many2many-mapping-to-custom-field-names
  2. With large no. of tables, I want to be able to define my casing logic in 10 lines instead of writing metadata on 100s of columns.. This is both painful and error prone.

Also, it is very easy to expose ToDBName() function to be modifiable.

@sjdweb
Copy link

sjdweb commented Jan 30, 2019

For google users, this can be done now, PR here: https://github.com/jinzhu/gorm/pull/2040

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

No branches or pull requests

3 participants