mirror of https://github.com/go-gorm/gorm.git
Don't raise error when get TableName even Scope has no db
This commit is contained in:
parent
07e2d49b22
commit
10668ee323
2
scope.go
2
scope.go
|
@ -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])
|
||||||
|
|
Loading…
Reference in New Issue