-
-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
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
field.Field 缺失运算方法 #1202
Comments
如果确定是数值运算,可以把这个字段gen field类型定义成float,或者int |
@qqxhb 你的建议值得商榷
|
@qqxhb 抱歉,我没有仔细阅读代码, |
@qqxhb 请问按目前的功能实现,我该如何构建下面的 SQL ?? UPDATE `user_wallet` SET `frozenBalance` = `frozenBalance` + 10.05 WHERE userId = 311 AND balance > `frozenBalance` + 10.05; |
model上的类型用decimal.Decimal就好 自定义Filed是否要加这些方法,我们讨论下 |
not in 也没有,既然是通用类型的 filed.Field 没有确定类型,应该加上相关方法,有开发者自己决定 用还是不用。不能因为可能会出现误用 而禁止。如果有人认为这样不安全,你可以用更准确的类型,比如field.Int. |
@shuqingzai 请问你解决这个问题了吗?能否展示下示例代码呢 |
@Catlickfish |
GORM Playground Link
Description
在
field.Field
中有求和方法,缺失一些方法参考:
gen/field/field.go
Line 69 in ebb6364
gen/field/int.go
Lines 70 to 98 in ebb6364
field.Field
应该与其它类型保持同样的方法,以便支持自定义类型如:使用
decimal.Decimal
作为金额字段类型时,无法运算,自增或自减The text was updated successfully, but these errors were encountered: