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

获取article接口返回的数据,tag_id字段和tag字段里的id值不一致 #39

Closed
fubd opened this issue Feb 4, 2019 · 2 comments

Comments

@fubd
Copy link

fubd commented Feb 4, 2019

{
"code": 200,
"msg": "ok",
"data": {
"id": 2,
"created_on": 0,
"modified_on": 0,
"deleted_on": 0,
"tag_id": 3,
"tag": {
"id": 0,
"created_on": 0,
"modified_on": 0,
"deleted_on": 0,
"name": "",
"created_by": "",
"modified_by": "",
"state": 0
},
...

@fubd
Copy link
Author

fubd commented Feb 4, 2019

err := db.Where("id = ? AND deleted_on = ? ", id, 0).First(&article).Related(&article.Tag).Error

这里where查询id时,似乎同时查询了blog_tag和blog_article两张表的id。当tag_id和article id一致时,才会返回正确的tag数据。

@eddycjy eddycjy closed this as completed in 0505512 Apr 6, 2019
@eddycjy
Copy link
Owner

eddycjy commented Apr 6, 2019

@fubd 已修复,感谢反馈 :)

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