Commit Graph

22 Commits

Author SHA1 Message Date
heige 50e85e14d4
Code optimize (#4415)
* optimize gormSourceDir replace

* fmt.Errorf adjust and Optimize for-break

* strings trim

* feat: avoid using the same name field and if..else optimization adjustment

* optimization callbacks/create.go Create func if...else logic

* fix: callbacks/create.go Create func

* fix FileWithLineNum func and add gormSourceDir unit test

* remove debug print and utils_filenum_test.go
2021-06-10 10:21:28 +08:00
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
Chris Faulkner 15a46bc042
Fix some typos (#4294) 2021-04-19 21:03:39 +08:00
Sivchari adf85d5b82
change the method of initializing slice (#4097)
* change the method of initializing slice and fixed the length to be specified as 0

* keep the association.go code in the var group

* keep the association.go code in the var group

* change to initializing in var group
2021-03-04 19:44:15 +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 db0cc4d60b Fix too long foreign key/checker names, close #4026 2021-02-01 10:37:12 +08:00
Jinzhu 66e8a72bf1 Support NameReplace for NamingStrategy, close #3779 2020-11-23 11:24:07 +08:00
alresvor a4c0c6b400
cache converted name (#3736)
BenchmarkToName-8     	  2322307	       521 ns/op	      88 B/op	       5 allocs/op
↓
BenchmarkToName-8     	19997366	        55.0 ns/op	       0 B/op	       0 allocs/op
2020-11-16 15:16:15 +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 6e38a2c2d5 Fix many2many join table name rule 2020-09-06 10:51:21 +08:00
Jinzhu 2d048d9ece SingularTable for JoinTable 2020-06-30 07:29:15 +08:00
Jinzhu fee1e4aafd Fix create foreign keys for many2many relations 2020-06-21 10:48:23 +08:00
Jinzhu 5790ba9ef4 Fix package path 2020-06-02 09:25:55 +08:00
Jinzhu e986371a42 Rename package name 2020-06-02 09:18:01 +08:00
Jinzhu 6d58b62fd4 Add sqlite migration tests 2020-02-22 20:57:29 +08:00
Jinzhu 0be4817ff9 Finish CreateConstraint 2020-02-22 11:15:51 +08:00
Jinzhu ad419855e9 Parse Indexes 2020-02-21 23:51:38 +08:00
Jinzhu 3cbd233758 Add more tests for parse schema relations 2020-02-02 00:03:56 +08:00
Jinzhu fd9b688084 Implement parse many2many relation 2020-02-01 18:02:19 +08:00
Jinzhu eea78f3f30 Implement parse relationship architecture 2020-02-01 12:46:52 +08:00
Jinzhu bc68fde6aa Implement naming strategy 2020-01-31 14:17:02 +08:00