bug fixed

This commit is contained in:
Lunny Xiao 2015-03-12 17:46:24 +08:00
parent 4d1ed756e4
commit 9ae245b54b
2 changed files with 12 additions and 2 deletions

View File

@ -3477,6 +3477,10 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
} }
} }
if st.LimitN > 0 {
condition = condition + fmt.Sprintf(" LIMIT %d", st.LimitN)
}
sqlStr = fmt.Sprintf("UPDATE %v SET %v, %v %v", sqlStr = fmt.Sprintf("UPDATE %v SET %v, %v %v",
session.Engine.Quote(session.Statement.TableName()), session.Engine.Quote(session.Statement.TableName()),
strings.Join(colNames, ", "), strings.Join(colNames, ", "),
@ -3503,6 +3507,10 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
} }
} }
if st.LimitN > 0 {
condition = condition + fmt.Sprintf(" LIMIT %d", st.LimitN)
}
sqlStr = fmt.Sprintf("UPDATE %v SET %v %v", sqlStr = fmt.Sprintf("UPDATE %v SET %v %v",
session.Engine.Quote(session.Statement.TableName()), session.Engine.Quote(session.Statement.TableName()),
strings.Join(colNames, ", "), strings.Join(colNames, ", "),

View File

@ -423,13 +423,14 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{},
pkField := reflect.Indirect(fieldValue).FieldByName(table.PKColumns()[0].FieldName) pkField := reflect.Indirect(fieldValue).FieldByName(table.PKColumns()[0].FieldName)
// fix non-int pk issues // fix non-int pk issues
//if pkField.Int() != 0 { //if pkField.Int() != 0 {
if pkField.IsValid() { if pkField.IsValid() && !isZero(pkField.Interface()) {
val = pkField.Interface() val = pkField.Interface()
} else { } else {
continue continue
} }
} else { } else {
//TODO: how to handler? //TODO: how to handler?
panic("not supported")
} }
} else { } else {
val = fieldValue.Interface() val = fieldValue.Interface()
@ -603,13 +604,14 @@ func buildConditions(engine *Engine, table *core.Table, bean interface{},
pkField := reflect.Indirect(fieldValue).FieldByName(table.PKColumns()[0].FieldName) pkField := reflect.Indirect(fieldValue).FieldByName(table.PKColumns()[0].FieldName)
// fix non-int pk issues // fix non-int pk issues
//if pkField.Int() != 0 { //if pkField.Int() != 0 {
if pkField.IsValid() { if pkField.IsValid() && !isZero(pkField.Interface()) {
val = pkField.Interface() val = pkField.Interface()
} else { } else {
continue continue
} }
} else { } else {
//TODO: how to handler? //TODO: how to handler?
panic("not supported")
} }
} else { } else {
val = fieldValue.Interface() val = fieldValue.Interface()