resolved merge from b1dfd648f2
This commit is contained in:
parent
6181361116
commit
81e690f8a8
12
session.go
12
session.go
|
@ -2910,6 +2910,8 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
||||||
|
|
||||||
var sqlStr, inSql string
|
var sqlStr, inSql string
|
||||||
var inArgs []interface{}
|
var inArgs []interface{}
|
||||||
|
doIncVer := false
|
||||||
|
var verValue *reflect.Value
|
||||||
if table.Version != "" && session.Statement.checkVersion {
|
if table.Version != "" && session.Statement.checkVersion {
|
||||||
if condition != "" {
|
if condition != "" {
|
||||||
condition = fmt.Sprintf("WHERE (%v) AND %v = ?", condition,
|
condition = fmt.Sprintf("WHERE (%v) AND %v = ?", condition,
|
||||||
|
@ -2932,7 +2934,13 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
||||||
session.Engine.Quote(table.Version)+" = "+session.Engine.Quote(table.Version)+" + 1",
|
session.Engine.Quote(table.Version)+" = "+session.Engine.Quote(table.Version)+" + 1",
|
||||||
condition)
|
condition)
|
||||||
|
|
||||||
condiArgs = append(condiArgs, table.VersionColumn().ValueOf(bean).Interface())
|
verValue, err = table.VersionColumn().ValueOf(bean)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
condiArgs = append(condiArgs, verValue.Interface())
|
||||||
|
doIncVer = true
|
||||||
} else {
|
} else {
|
||||||
if condition != "" {
|
if condition != "" {
|
||||||
condition = "WHERE " + condition
|
condition = "WHERE " + condition
|
||||||
|
@ -2959,6 +2967,8 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
||||||
res, err := session.exec(sqlStr, args...)
|
res, err := session.exec(sqlStr, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
|
} else if doIncVer {
|
||||||
|
verValue.SetInt(verValue.Int() + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if table.Cacher != nil && session.Statement.UseCache {
|
if table.Cacher != nil && session.Statement.UseCache {
|
||||||
|
|
Loading…
Reference in New Issue