From 10668ee32366f186a9dd1445b6fd00ac7a5bbb84 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 20 Aug 2014 10:49:48 +0800 Subject: [PATCH] Don't raise error when get TableName even Scope has no db --- scope.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scope.go b/scope.go index 4b934bf0..9eb672ad 100644 --- a/scope.go +++ b/scope.go @@ -204,7 +204,7 @@ func (scope *Scope) TableName() string { str := ToSnake(data.Type().Name()) - if !scope.db.parent.singularTable { + if scope.db != nil && !scope.db.parent.singularTable { for index, reg := range pluralMapKeys { if reg.MatchString(str) { return reg.ReplaceAllString(str, pluralMapValues[index])