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

在jsd如何支持字段为type类型 #7

Open
carolove opened this issue Mar 21, 2018 · 2 comments
Open

在jsd如何支持字段为type类型 #7

carolove opened this issue Mar 21, 2018 · 2 comments

Comments

@carolove
Copy link
Contributor

carolove commented Mar 21, 2018

eg:

type ReportStatus int

type DotCrawlInfo struct {
	ReportStatus     entity.ReportStatus `jsd:"report_status"`
	WebsiteStatus    entity.ReportStatus `jsd:"website_status"`
}

在jsd中反射出来的时候提示错误

infos = []*model.DotCrawlInfo{}
db := gsd.MustOpen(_TABLE_SQL_SITE_RECORD)
err = db.Select( _ColReportStatus, _ColWebsiteStatus).From(_Table).
	Where(filter).
	Page(PI.PageIndex, PI.PageSize).Fill(&infos)
if err != nil {
	fmt.Println("Error:", err.Error())
}
return

提示类型无法反射无法从tinyiint(4) -> type ReportStatus int

这种如何解决~~

@cuigh
Copy link
Owner

cuigh commented Mar 22, 2018

基于性能考虑,gsd 在反射这一块做了极大的优化,所以目前并没有实现自动类型转换。但最新版已经添加对基础类型的自定义类型的兼容,只要底层类型是一致的,就没有问题,如数据库类型是 int32,自定义类型也是基于 int32 的,就可以兼容,但如果自定义类型是基于 int64 的就不能兼容了

@carolove
Copy link
Contributor Author

carolove commented Mar 22, 2018 via email

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

No branches or pull requests

2 participants