GORM Playground Link
https://github.com/go-gorm/playground/pull/1
result = DB.DBLink.Model(model).Select([]string{"ID", "Nickname", "AvatarPicUrl"}).Scan(scanDest)
上面的代码会生成sql语句是:SELECT `id`,Nickname,`AvatarPicUrl` 。。。(注意Nickname是 没引号的),虽然似乎执行这条sql并不会报错,但是当执行后的数据scan到目的结构体实例scanDest时候,scanDest的NickName字段是不会scan数据成功的,也就是没有数据,但是如果我将上面的代码改为:
result = DB.DBLink.Model(model).Select([]string{"ID", "NickName", "AvatarPicUrl"}).Scan(scanDest)//仅NickName不同
则生成的sql语句是SELECT `id`,`Nickname`,`AvatarPicUrl` 。。。
并且正常scan数据到scanDest对象上面,不提供其他demo或者playground,hub主自己尝试便知!
Comment From: github-actions[bot]
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.io ✨ Search Before Asking ✨
Comment From: AnkoGo123
好像是我这边原因,应该是我这边代码原因,打扰了
Comment From: github-actions[bot]
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.io ✨ Search Before Asking ✨