Commit Graph

6 Commits

Author SHA1 Message Date
Sky34gl3 a855fe6402
Fixed naming longer than 64 characters (#4310)
Co-authored-by: Mickael MAUGER <mickael.mauger@almerys.com>
2021-04-22 13:11:19 +08:00
Joel Nordell 5744e29fbd
Replacer interface for more flexible NamingStrategy (#4042)
* Change NameReplacer to an interface, allowing custom Replacers.

* Add NoLowerCase option to skip the snake_casing of names.

* Move sync.Map from global variable into member of NamingStrategy.

This maintains backward compatibility by making the smap optional - the
NamingStrategy still works if it is nil. gorm.Open activates it by
calling Init() if the given Namer is a schema.NamingStrategy.

Also, this changes the key stored in the smap to be the original name,
instead of the replaced name.

* Refactor NamingStrategy tests to add more assertions about how and when Replacers get called.

* Remove the name cache from NamingStrategy.
2021-02-14 08:16:24 +08:00
Jinzhu 66e8a72bf1 Support NameReplace for NamingStrategy, close #3779 2020-11-23 11:24:07 +08:00
Jinzhu a2faa41cbe Refactor NamingStrategy, close #3540 2020-09-28 10:55:27 +08:00
Jinzhu 1a526e6802 Fix NamingStrategy with embedded struct, close #3513 2020-09-24 11:32:38 +08:00
Jinzhu bc68fde6aa Implement naming strategy 2020-01-31 14:17:02 +08:00