forked from mirror/gorm
Fix ToDBName method
from FiledX > fieldx to FieldX > field_x
This commit is contained in:
parent
45ccb13437
commit
0493e786b8
3
utils.go
3
utils.go
|
@ -97,6 +97,9 @@ func ToDBName(name string) string {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buf.WriteRune(v)
|
buf.WriteRune(v)
|
||||||
|
if i == len(value)-2 && nextCase == upper {
|
||||||
|
buf.WriteRune('_')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
currCase = upper
|
currCase = upper
|
||||||
|
|
|
@ -9,11 +9,13 @@ import (
|
||||||
func TestToDBNameGenerateFriendlyName(t *testing.T) {
|
func TestToDBNameGenerateFriendlyName(t *testing.T) {
|
||||||
var maps = map[string]string{
|
var maps = map[string]string{
|
||||||
"": "",
|
"": "",
|
||||||
|
"X": "x",
|
||||||
"ThisIsATest": "this_is_a_test",
|
"ThisIsATest": "this_is_a_test",
|
||||||
"PFAndESI": "pf_and_esi",
|
"PFAndESI": "pf_and_esi",
|
||||||
"AbcAndJkl": "abc_and_jkl",
|
"AbcAndJkl": "abc_and_jkl",
|
||||||
"EmployeeID": "employee_id",
|
"EmployeeID": "employee_id",
|
||||||
"SKU_ID": "sku_id",
|
"SKU_ID": "sku_id",
|
||||||
|
"FieldX": "field_x",
|
||||||
"HTTPAndSMTP": "http_and_smtp",
|
"HTTPAndSMTP": "http_and_smtp",
|
||||||
"HTTPServerHandlerForURLID": "http_server_handler_for_url_id",
|
"HTTPServerHandlerForURLID": "http_server_handler_for_url_id",
|
||||||
"UUID": "uuid",
|
"UUID": "uuid",
|
||||||
|
|
Loading…
Reference in New Issue