Closed qinghai5060 closed 5 months ago
Same issue for me, hope to provide some function like:
mock.ExpectExec(regexp.QuoteMeta("UPDATE `quota`")).
WithSets(map[string]driver.Value{
"used": 1,
"update_at": time.Now(),
})
I write some code to solve this problem, but I think this code is too tricky to open a MR. Take your own responsibility to use it. If someone has some better idea, plz let me know. :)
https://github.com/Strang/go-sqlmock/commit/f633abcc5e0d0135cf45c939da4b49d44c3e9d3c
Hi @qinghai5060! Closing as there is not enough information to help you, unfortunately. If the problem persists, reopen and provide the following information:
sqlmock
version.Thank you!
what happened: when I want to test
expected sql I tested with
UPDATE "quota" SET "used" = $1, "update_at" = $2 WHERE "id" ...
, It sometimes happen that the actual is "UPDATE "quota" SET "updateat" = $1, "used" = $2 WHERE "id"", and error occures like: [UPDATE "quota" SET "update_at" = $1, "used" = $2 WHERE "id" IN ( SELECT T0."id" FROM"quota" T0 WHERE T0."project" = $3 AND T0."type" = $4 )] -2021-09-27 02:50:17.460540895 +0000 UTC
,11
,project001
,key
- call to ExecQuery 'UPDATE "quota" SET "updateat" = $1, "used" = $2 WHERE "id" IN ( SELECT T0."id" FROM "quota" T0 WHERE T0."project" = $3 AND T0."type" = $4 )' with args [{Name: Ordinal:1 Value:2021-09-27 02:50:17.460540895 +0000 UTC} {Name: Ordinal:2 Value:11} {Name: Ordinal:3 Value:project001} {Name: Ordinal:4 Value:key}] was not expected I use beego orm lib and orm.Params is a map. For that reason, it is not sorted. Is there any way to solve this?