I am a beginner, I don't understand why insert decimal type field "money", it echo "money (Decimal(18, 2)): unexpected type string"
func main() {
dsn := "tcp://localhost.39:9000?database=test&read_timeout=10&write_timeout=20"
db, err := gorm.Open(clickhouse.Open(dsn), &gorm.Config{
NamingStrategy: schema.NamingStrategy{
SingularTable: true,
},
})
if err != nil {
log.Error(err.Error())
}
err = db.Create(&Orderinfo{
Id: uuid.New().String(),
Money: decimal.New(15001, -3),
Vip: "VIP0",
CreateTime: time.Now().UnixMicro(),
}).Error
if err != nil {
log.Error(err.Error())
}
}
create table if not exists test.orderinfo
(
id String ,
money Decimal64(2),
vip String,
create_time Int64
) engine = MergeTree
partition by (create_time)
order by id;
