Don't panic with ToDbName

This commit is contained in:
Jinzhu 2016-01-16 09:40:13 +08:00
parent 67874f9232
commit 4351917c45
2 changed files with 5 additions and 0 deletions

View File

@ -53,6 +53,10 @@ func ToDBName(name string) string {
return v return v
} }
if name == "" {
return ""
}
var ( var (
value = commonInitialismsReplacer.Replace(name) value = commonInitialismsReplacer.Replace(name)
buf = bytes.NewBufferString("") buf = bytes.NewBufferString("")

View File

@ -8,6 +8,7 @@ import (
func TestToDBNameGenerateFriendlyName(t *testing.T) { func TestToDBNameGenerateFriendlyName(t *testing.T) {
var maps = map[string]string{ var maps = map[string]string{
"": "",
"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",