Merge pull request #1408 from Konboi/fix/util-to-db-name

Fix ToDBName method
This commit is contained in:
Jinzhu 2017-04-18 22:49:33 +08:00 committed by GitHub
commit abf1fc7808
2 changed files with 5 additions and 0 deletions

View File

@ -97,6 +97,9 @@ func ToDBName(name string) string {
}
} else {
buf.WriteRune(v)
if i == len(value)-2 && nextCase == upper {
buf.WriteRune('_')
}
}
} else {
currCase = upper

View File

@ -9,11 +9,13 @@ import (
func TestToDBNameGenerateFriendlyName(t *testing.T) {
var maps = map[string]string{
"": "",
"X": "x",
"ThisIsATest": "this_is_a_test",
"PFAndESI": "pf_and_esi",
"AbcAndJkl": "abc_and_jkl",
"EmployeeID": "employee_id",
"SKU_ID": "sku_id",
"FieldX": "field_x",
"HTTPAndSMTP": "http_and_smtp",
"HTTPServerHandlerForURLID": "http_server_handler_for_url_id",
"UUID": "uuid",