Fix api_keies

This commit is contained in:
George Thomas 2015-08-25 14:35:40 +01:00
parent 51c6ee46c1
commit 4db003f0cd

View File

@ -5,10 +5,11 @@ import (
"fmt"
"go/ast"
"reflect"
"regexp"
"strconv"
"strings"
"time"
"github.com/qor/inflection"
)
var modelStructs = map[reflect.Type]*ModelStruct{}
@ -63,9 +64,6 @@ type Relationship struct {
JoinTableHandler JoinTableHandlerInterface
}
var pluralMapKeys = []*regexp.Regexp{regexp.MustCompile("ch$"), regexp.MustCompile("ss$"), regexp.MustCompile("sh$"), regexp.MustCompile("day$"), regexp.MustCompile("y$"), regexp.MustCompile("x$"), regexp.MustCompile("([^s])s?$")}
var pluralMapValues = []string{"ches", "sses", "shes", "days", "ies", "xes", "${1}s"}
func (scope *Scope) GetModelStruct() *ModelStruct {
var modelStruct ModelStruct
@ -105,11 +103,7 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
} else {
name := ToDBName(scopeType.Name())
if scope.db == nil || !scope.db.parent.singularTable {
for index, reg := range pluralMapKeys {
if reg.MatchString(name) {
name = reg.ReplaceAllString(name, pluralMapValues[index])
}
}
name = inflection.Plural(name)
}
modelStruct.TableName = func(*DB) string {