mirror of https://github.com/go-gorm/gorm.git
Fix errors in field.go, model.go
This commit is contained in:
parent
cc03f438ef
commit
045b3b6fbc
6
field.go
6
field.go
|
@ -53,7 +53,7 @@ func (f *Field) sqlTag() (str string) {
|
|||
}
|
||||
}
|
||||
|
||||
typ, addational_typ, size := parseSqlTag(f.structField.Tag.Get(tagIdentifier))
|
||||
typ, addational_typ, size := parseSqlTag(f.structField.Tag.Get(f.model.do.db.tagIdentifier))
|
||||
|
||||
if typ == "-" {
|
||||
return
|
||||
|
@ -61,9 +61,9 @@ func (f *Field) sqlTag() (str string) {
|
|||
|
||||
if len(typ) == 0 {
|
||||
if f.isPrimaryKey {
|
||||
typ = f.model.do.chain.d.dialect.PrimaryKeyTag(value, size)
|
||||
typ = f.model.do.db.dialect.PrimaryKeyTag(value, size)
|
||||
} else {
|
||||
typ = f.model.do.chain.d.dialect.SqlTag(value, size)
|
||||
typ = f.model.do.db.dialect.SqlTag(value, size)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
model.go
4
model.go
|
@ -191,7 +191,7 @@ func (m *Model) tableName() (str string) {
|
|||
|
||||
str = toSnake(m.typeName())
|
||||
|
||||
if !singularTableName {
|
||||
if !m.do.db.singularTable {
|
||||
pluralMap := map[string]string{"ch": "ches", "ss": "sses", "sh": "shes", "day": "days", "y": "ies", "x": "xes", "s?": "s"}
|
||||
for key, value := range pluralMap {
|
||||
reg := regexp.MustCompile(key + "$")
|
||||
|
@ -205,7 +205,7 @@ func (m *Model) tableName() (str string) {
|
|||
}
|
||||
|
||||
func (m *Model) callMethod(method string) {
|
||||
if m.data == nil || m.do.chain.hasError() {
|
||||
if m.data == nil || m.do.db.hasError() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue