Fix errors in field.go, model.go

This commit is contained in:
Jinzhu 2013-11-16 12:22:18 +08:00
parent cc03f438ef
commit 045b3b6fbc
2 changed files with 5 additions and 5 deletions

View File

@ -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)
}
}

View File

@ -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
}