Don't raise error when get TableName even Scope has no db

This commit is contained in:
Jinzhu 2014-08-20 10:49:48 +08:00
parent 07e2d49b22
commit 10668ee323
1 changed files with 1 additions and 1 deletions

View File

@ -204,7 +204,7 @@ func (scope *Scope) TableName() string {
str := ToSnake(data.Type().Name()) str := ToSnake(data.Type().Name())
if !scope.db.parent.singularTable { if scope.db != nil && !scope.db.parent.singularTable {
for index, reg := range pluralMapKeys { for index, reg := range pluralMapKeys {
if reg.MatchString(str) { if reg.MatchString(str) {
return reg.ReplaceAllString(str, pluralMapValues[index]) return reg.ReplaceAllString(str, pluralMapValues[index])