DB model,字段 设置 int64类型,对应查询的事时间戳,报错 #1714

Closed
opened 2020-06-16 07:39:36 +00:00 by jerry · 2 comments
Member

image

发现问题在这里,时间类型转int64类型,转换报错
image

解决方案:
在判断类型处,最后加个是否是时间的判断,如果是,转换成时间戳
image

![image](/attachments/fe80610d-e4c6-4a1d-9f12-f353198735e4) 发现问题在这里,时间类型转int64类型,转换报错 ![image](/attachments/ffbb73b7-4d95-4e0b-9110-7069a540cab0) 解决方案: 在判断类型处,最后加个是否是时间的判断,如果是,转换成时间戳 ![image](/attachments/a12082b1-1475-42e0-9dcc-90b885992e83)
Author
Member

补充说明:
结构体中,xtime.Time 是 int64 类型

补充说明: 结构体中,xtime.Time 是 int64 类型
Owner
type MyTime int64

func (m *MyTime) FromDB(bs []byte) error {

}

func (m *MyTime) ToDB() ([]byte, error) {

}
```go type MyTime int64 func (m *MyTime) FromDB(bs []byte) error { } func (m *MyTime) ToDB() ([]byte, error) { } ```
lunny added the
kind
question
label 2020-06-16 08:47:51 +00:00
lunny closed this issue 2021-01-05 03:04:23 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1714
No description provided.