xorm icon indicating copy to clipboard operation
xorm copied to clipboard

能加入 Decimal 类型的支持吗?

Open zjxpcyc opened this issue 7 years ago • 2 comments

不要把 Decimal 类型转给 Go string 类型,能转成这个包 math/big 类型吗?

zjxpcyc avatar Jun 22 '17 02:06 zjxpcyc

@lunny 目前还是转换成string类型啊,我手动改成float64... 比如说以下字段BalanceTradeCredit都是decimal类型,Balance是DECIMAL(14,2),TradeCredit是DECIMAL(5,2),都转换成string类型了。执行sql的时候会报错,我需要手动改成float64

type User struct {
	Id          int       `xorm:"not null pk autoincr comment('用户id') INT(11)"`
	Username    string    `xorm:"not null default '' comment('用户名') unique CHAR(100)"`
	PhoneNo     string    `xorm:"not null default '' comment('用户手机') unique CHAR(11)"`
	Password    string    `xorm:"not null default '' comment('用户密码') VARCHAR(100)"`
	Balance     string    `xorm:"not null default 0.00 comment('用户余额') DECIMAL(14,2)"`
	TradeCredit string    `xorm:"not null default 0.00 comment('交易信用分') DECIMAL(5,2)"`
	CreateAt    time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('插入时间') TIMESTAMP"`
	UpdateTs    time.Time `xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
}

huahuayu avatar May 05 '19 05:05 huahuayu

我去 两年了 decimal还是string

shyandsy avatar Jun 13 '19 10:06 shyandsy