Open congjunhua opened 1 year ago
将time.Time
改为string
可以规避报错,虽然不合理且徒增了类型转化的步骤,但暂时也只能这样了。
望早日修复。
You can try parseTime=True
in your DSN, just like
gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
You can try
parseTime=True
in your DSN, just likegorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
用了,但不起作用。
You can try
parseTime=True
in your DSN, just likegorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
用了,但不起作用。
Could you provide more detailed information
You can try
parseTime=True
in your DSN, just likegorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
thanks, it works well
You can try
parseTime=True
in your DSN, just likegorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
用了,但不起作用。
Could you provide more detailed information
parseTime=True. is support Mysql date and datetime , not support time
You can try
parseTime=True
in your DSN, just likegorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local
用了,但不起作用。
Could you provide more detailed information
parseTime=True. is support Mysql date and datetime , not support time
Yes, because github.com/go-sql-driver/mysql
does not support time, see https://github.com/go-sql-driver/mysql/issues/849#issuecomment-416943196 and https://github.com/go-sql-driver/mysql/issues/849#issuecomment-417209270.
If you want to convert MySQL's Time
to time.Time, this is an example:
if you want to MySQL's Time
to time.Duration, you can use gorm.io/datatypes
, see https://github.com/go-gorm/datatypes/blob/master/time.go. Similar, so you can also convert it to time.Time
https://github.com/golang-module/carbon time.Time 的替代方案,gorm兼容性非常好
Your Question
Mysql
中的TIME
类型的字段映射Go
的time.Time
类型时报标题错误。The document you expected this should be explained
Expected answer
如何解决?