-
Notifications
You must be signed in to change notification settings - Fork 4
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
[Feedback] Use select query into struct occour 'name "title": destination not a pointer' error #18
Comments
感谢关注使用和反馈!
mysql的查询本来就是需要明确database name的,分几种情况:
我个人比较喜欢每次语句带上database name(database_name.table_name):
|
前面的错误,可能是由于你的语句里没有明确database name所以查询到的结果赋值失败,先试试明确database后正确写法是否有问题吧 |
哦这个我前面理解错了,你的意思是说,sql查询所有字段出来、例如10个字段,结构体字段少于10个所以失败是吧? |
是的。数据库定义 10 个字段,但是结构体查询仅定义 1个,从而出现上述的错误 |
对的,就是这里这个bug 看了下数组接收器的时候是没这个bug的,struct漏掉了: struct没有对应字段的时候缺少了有效的receiver,刚提交到了这个分支,试下吧: go get -u github.com/lesismal/sqlw@nil_receiver_fields |
可以的,能正常工作了。谢谢 fix 👍 |
好的,感谢反馈 👍 发布了 v1.1.0 ,可以用它了 |
Hi, @lesismal 老大
在使用 query to struct 的时候,要求 struct 必须定义完整的字段,否则会提示以下错误
但在使用 query to struct slice 的时候,则能完整输出结果
是否开发者在使用 sqlw query to struct 时候需要明确数据库的各个字段?
Example Code
Output print ( remove panic log)
The text was updated successfully, but these errors were encountered: