From 47f1e2bef9760fd4cc128742679e838b55c51d21 Mon Sep 17 00:00:00 2001 From: yuancjun <35465543+yuancjun@users.noreply.github.com> Date: Thu, 14 Feb 2019 17:44:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=20version=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=20Add=20=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当 结构体开启 version tag 时, 使用 update 方法, 第一个参数(更新的字段)结构体指针中 Version 字段默认为 0, 导致找不到更新的数据. 调用的方式为: ``` update := &FeedItem{ DatePublished: "2019-01-9", } engine.Where("date_published = ?", "2019-01-11").Update(update) ``` 生成的 sql 类似于: ``` [xorm] [info] 2019/02/14 17:36:46.057228 [SQL] UPDATE "feed_item" SET "date_published" = $1, "updated" = $2, "version" = "version" + 1 WHERE (date_published = $3) AND "version"=$4 []interface {}{"2019-01-9", 1550137006, "2019-01-11", 0} ``` --- session_update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session_update.go b/session_update.go index 6bd16aaf..71acd199 100644 --- a/session_update.go +++ b/session_update.go @@ -280,7 +280,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6 return 0, err } - cond = cond.And(builder.Eq{session.engine.Quote(table.Version): verValue.Interface()}) + // cond = cond.And(builder.Eq{session.engine.Quote(table.Version): verValue.Interface()}) colNames = append(colNames, session.engine.Quote(table.Version)+" = "+session.engine.Quote(table.Version)+" + 1") }