We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Go
go version go1.20.3 darwin/amd64
GoFrame
GoFrame CLI Tool v2.5.1, https://goframe.org/ GoFrame Version: v2.5.2 in current go.mod CLI Installed At: /usr/local/bin/gf CLI Built Detail: Go Version: go1.20.4 GF Version: v2.5.1 Git Commit: 2023-07-26 21:27:58 e0e0043 Build Time: 2023-07-26 21:32:56
Yes
When use the Where condition and The value with Counter other field in ORM Update
In official example https://goframe.org/pages/viewpage.action?pageId=1114238
updateData := g.Map{ "views": &gdb.Counter{ Field: "clicks", Value: 1, }, } // UPDATE `article` SET `views`=`clicks`+1 WHERE `id`=1 result, err := db.Update("article", updateData, "id", 1)
In my example
var ( columns = dao.Order.Columns() ctx = context.TODO() ) data := g.Map{ columns.AfterSurplus: &gdb.Counter{ Field: columns.Amount, Value: 0, }, } affect, err := dao.Order. Ctx(ctx). Unscoped(). Data(data). Where(columns.OrderSn, "1242308294272199"). UpdateAndGetAffected() convey.So(err, convey.ShouldBeNil) convey.So(affect, convey.ShouldBeGreaterThan, 0)
Stack INFO:
Actual: 'data cannot be empty'
UPDATE `order` SET `after_surplus`=amount+0 WHERE `order_sn`='1242308294272199'
columns.AfterSurplus: gdb.Raw(columns.Amount + "+" + strconv.Itoa(0)), //columns.AfterSurplus: &gdb.Counter{ // Field: columns.Amount, // Value: 0, //},
The text was updated successfully, but these errors were encountered:
@qq413434162 That is the orm checks the updating increment value 0 is meaningless, it so ignores the updates data. You can change the data as follows:
0
data := g.Map{ columns.AfterSurplus: &gdb.Counter{ Field: columns.Amount, Value: 1, }, }
Sorry, something went wrong.
No branches or pull requests
1. What version of
Go
and system type/arch are you using?go version go1.20.3 darwin/amd64
2. What version of
GoFrame
are you using?GoFrame CLI Tool v2.5.1, https://goframe.org/
GoFrame Version: v2.5.2 in current go.mod
CLI Installed At: /usr/local/bin/gf
CLI Built Detail:
Go Version: go1.20.4
GF Version: v2.5.1
Git Commit: 2023-07-26 21:27:58 e0e0043
Build Time: 2023-07-26 21:32:56
3. Can this issue be re-produced with the latest release?
Yes
4. What did you do?
When use the Where condition and The value with Counter other field in ORM Update
In official example
https://goframe.org/pages/viewpage.action?pageId=1114238
In my example
Stack INFO:
Actual: 'data cannot be empty'
5. What did you expect to see?
6. What did you see instead?
The text was updated successfully, but these errors were encountered: