forked from mirror/gorm
By default, pluralize table name
This commit is contained in:
parent
14fdbdd965
commit
a80a0a1636
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 != nil && !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