Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

去除 version 字段的 Add 条件 #1230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

去除 version 字段的 Add 条件 #1230

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Feb 14, 2019

当 结构体开启 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}

当 结构体开启 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}
```
@codecov-io
Copy link

Codecov Report

Merging #1230 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1230      +/-   ##
==========================================
- Coverage   57.35%   57.33%   -0.02%     
==========================================
  Files          43       43              
  Lines        7797     7796       -1     
==========================================
- Hits         4472     4470       -2     
  Misses       2771     2771              
- Partials      554      555       +1
Impacted Files Coverage Δ
session_update.go 55.55% <ø> (-0.15%) ⬇️
xorm.go 68.18% <0%> (-1.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e410f04...47f1e2b. Read the comment docs.

@lunny
Copy link
Member

lunny commented Feb 17, 2019

Could you add some tests?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants