-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
使用 whereLT decimal 类型列的问题 #3915
Comments
@Weishan-Allen 请给定可复现该问题的最小可运行代码。 |
@Weishan-Allen Please provide the smallest runnable code that can reproduce the problem. |
应该不是decimal的问题 |
It should not be a problem with decimal. |
@gqcn @wwwfeng 我修改了值证明了 确实如 @wwwfeng 所说一致,但打印出来sql非常有迷惑性。 type ScanTest struct {
a float64
b float64
}
func Test(ctx context.Context) {
var scanTest *ScanTest
err := dao.Test.Ctx(ctx).WhereLT("a", gdb.Raw("`b`")).Scan(&scanTest)
if err != nil {
return
}
// 日志: [rows:0 ] SELECT `a`,`b` FROM `test` WHERE `a` < `b` LIMIT 1
err = dao.Test.Ctx(ctx).WhereGT("b", gdb.Raw("`a`")).Scan(&scanTest)
if err != nil {
return
}
// 日志: [rows:1 ] SELECT `a`,`b` FROM `hg_test` WHERE `b` > `a` LIMIT 1
} |
@gqcn @wwwfeng I modified the value to prove that it is indeed consistent as @wwwfeng said, but the printed sql is very confusing. typeScanTest struct {
a float64
b float64
}
func Test(ctx context.Context) {
var scanTest *ScanTest
err := dao.Test.Ctx(ctx).WhereLT("a", gdb.Raw("`b`")).Scan(&scanTest)
if err != nil {
return
}
// Log: [rows:0 ] SELECT `a`,`b` FROM `test` WHERE `a` < `b` LIMIT 1
err = dao.Test.Ctx(ctx).WhereGT("b", gdb.Raw("`a`")).Scan(&scanTest)
if err != nil {
return
}
// Log: [rows:1 ] SELECT `a`,`b` FROM `hg_test` WHERE `b` > `a` LIMIT 1
} |
这让我以为它正常的工作了,所以WhereGT or LT 不支持第二个参数使用gdb.Raw吗 |
This makes me think it is working normally, so WhereGT or LT does not support the second parameter using gdb.Raw? |
支持呀!你看你之前发的结果。 |
Support it! Look at the results you posted before. |
@gqcn 抱歉最近有点忙,我现在新开了一个项目 数据库表结构以及数据如下 很明显 a > b 的记录 和 b > a 的记录各一条 现在我写了个示例去查询 a < b 和 a > b 的例子
打印的日志:
这似乎并没有工作 |
@Weishan-Allen 好的,我看看。 |
@Weishan-Allen Okay, let me see. |
Go version
1.23.2
GoFrame version
2.7.4
Can this bug be reproduced with the latest release?
Option Yes
What did you do?
使用
var v []*entity.V
WhereLT(dao.x.Columns().a, gdb.Raw(dao.x.Columns().b)).Scan(&v)
数据库 a,b 均为 decimal 类型 且 a为0.00 并且b 是大于0.00的任意数
且表只有一条记录(应该关系不大)
What did you see happen?
row 返回为0条记录
What did you expect to see?
row 返回为1
如果采用WhereGT 则可以正常返回
var v []*entity.V
WhereGT(dao.x.Columns().b, gdb.Raw(dao.x.Columns().a)).Scan(&v)
数据库 a,b 均为 decimal 类型 且 a为0.00 并且b 是大于0.00的任意数
猜测应该是和 0值有关
The text was updated successfully, but these errors were encountered: