method Update(...) 's first params now support map and map's ptr

This commit is contained in:
Lunny Xiao 2013-09-20 00:07:39 +08:00
parent 29fe0b6f80
commit 365812143b
2 changed files with 4 additions and 4 deletions

View File

@ -162,7 +162,7 @@ func update(engine *Engine, t *testing.T) {
}
condi := Condi{"username": "zzz", "height": 0.0, "departname": ""}
_, err = engine.Table(&user).Id(1).Update(condi)
_, err = engine.Table(&user).Id(1).Update(&condi)
if err != nil {
t.Error(err)
panic(err)

View File

@ -1410,7 +1410,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
table = session.Engine.AutoMap(bean)
session.Statement.RefTable = table
colNames, args = BuildConditions(session.Engine, table, bean)
if table.Updated != "" {
if session.Statement.UseAutoTime && table.Updated != "" {
colNames = append(colNames, session.Engine.Quote(table.Updated)+" = ?")
args = append(args, time.Now())
}
@ -1421,13 +1421,13 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
table = session.Statement.RefTable
colNames = make([]string, 0)
args = make([]interface{}, 0)
bValue := reflect.ValueOf(bean)
bValue := reflect.Indirect(reflect.ValueOf(bean))
for _, v := range bValue.MapKeys() {
colNames = append(colNames, session.Engine.Quote(v.String())+" = ?")
args = append(args, bValue.MapIndex(v).Interface())
}
if table.Updated != "" {
if session.Statement.UseAutoTime && table.Updated != "" {
colNames = append(colNames, session.Engine.Quote(table.Updated)+" = ?")
args = append(args, time.Now())
}