From 4351917c45b202f389f3efe0a1e2bd3493d2848a Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sat, 16 Jan 2016 09:40:13 +0800 Subject: [PATCH] Don't panic with ToDbName --- utils.go | 4 ++++ utils_test.go | 1 + 2 files changed, 5 insertions(+) diff --git a/utils.go b/utils.go index d47065bf..a4cf0b8c 100644 --- a/utils.go +++ b/utils.go @@ -53,6 +53,10 @@ func ToDBName(name string) string { return v } + if name == "" { + return "" + } + var ( value = commonInitialismsReplacer.Replace(name) buf = bytes.NewBufferString("") diff --git a/utils_test.go b/utils_test.go index 81b8ce9d..0e88a8b7 100644 --- a/utils_test.go +++ b/utils_test.go @@ -8,6 +8,7 @@ import ( func TestToDBNameGenerateFriendlyName(t *testing.T) { var maps = map[string]string{ + "": "", "ThisIsATest": "this_is_a_test", "PFAndESI": "pf_and_esi", "AbcAndJkl": "abc_and_jkl",