bug fixed
This commit is contained in:
parent
4d1ed756e4
commit
9ae245b54b
|
@ -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",
|
||||
session.Engine.Quote(session.Statement.TableName()),
|
||||
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",
|
||||
session.Engine.Quote(session.Statement.TableName()),
|
||||
strings.Join(colNames, ", "),
|
||||
|
|
|
@ -423,13 +423,14 @@ func buildUpdates(engine *Engine, table *core.Table, bean interface{},
|
|||
pkField := reflect.Indirect(fieldValue).FieldByName(table.PKColumns()[0].FieldName)
|
||||
// fix non-int pk issues
|
||||
//if pkField.Int() != 0 {
|
||||
if pkField.IsValid() {
|
||||
if pkField.IsValid() && !isZero(pkField.Interface()) {
|
||||
val = pkField.Interface()
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
//TODO: how to handler?
|
||||
panic("not supported")
|
||||
}
|
||||
} else {
|
||||
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)
|
||||
// fix non-int pk issues
|
||||
//if pkField.Int() != 0 {
|
||||
if pkField.IsValid() {
|
||||
if pkField.IsValid() && !isZero(pkField.Interface()) {
|
||||
val = pkField.Interface()
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
//TODO: how to handler?
|
||||
panic("not supported")
|
||||
}
|
||||
} else {
|
||||
val = fieldValue.Interface()
|
||||
|
|
Loading…
Reference in New Issue