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.

无法使用decimal #1053

Open
fanspace opened this issue Jul 27, 2018 · 0 comments
Open

无法使用decimal #1053

fanspace opened this issue Jul 27, 2018 · 0 comments

Comments

@fanspace
Copy link

xorm的命令行工具默认将decimal(8,2)做为string,因大量的转型及运算
所以在项目中使用了https://github.com/shopspring/decimal
在model中使用如下
Charge decimal.Decimal json:"charge" xorm:"not null DECIMAL(8,2)"
可以顺利插入至数据库,但取值时出现问题
例如
方法中使用has, err := db.Orm.Where("usid = ?", usid).Get(&charge) 查询,
但生成的sql 为
SELECT usid, charge, expiretime, type, status, remark FROM charge WHERE (usid = ? and charge = ? ) LIMIT 1 []interface {}{198,0}
多了一个charge = ? 的查询条件
如果改回string则一切正常。

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

No branches or pull requests

1 participant