Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom struct returns time Time is zero #7232

Closed
miajio opened this issue Oct 10, 2024 · 2 comments
Closed

Custom struct returns time Time is zero #7232

miajio opened this issue Oct 10, 2024 · 2 comments
Assignees
Labels

Comments

@miajio
Copy link

miajio commented Oct 10, 2024

// LoginResponse 登录响应
type LoginResponse struct {
Token string json:"token"
Id int64 json:"id"
AccountNo string json:"accountNo"
Mobile string json:"mobile"
Account string json:"account"
Nickname string json:"nickName"
AvatarId int64 json:"avatarId"
AvatarPath string json:"avatarPath"
Sex string json:"sex"
CreateTime db.Time json:"createTime"
UpdateTime db.Time json:"updateTime"
Status string json:"status"
}

var res *LoginResponse
I use db.Raw(select tai.id as 'id', tai.accountNo as 'accountNo', tai.mobile as 'mobile', tai.account as 'account', tai.nickname as 'nickname', tai.avatarId as 'avatarId', tfi.path as 'avatarPath', tai.sex as 'sex', tai.createTime as 'createTime', tai.updateTime as 'updateTime', tai.status as 'status' from tb_account_info as tai left join tb_file_info as tfi on tai.avatarId = tfi.id and tfi.deleteTime is null where tai.id = ?, 1).Scan(&res)

res in createTime and updateTime value is zero

@miajio miajio added the type:question general questions label Oct 10, 2024
@github-actions github-actions bot added type:missing reproduction steps missing reproduction steps and removed type:question general questions labels Oct 10, 2024
@miajio
Copy link
Author

miajio commented Oct 10, 2024

What should I do if the date of the custom structure receiving the native SQL result is zero?

Copy link

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.ioSearch Before Asking

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

No branches or pull requests

2 participants