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

many2many Update更新重复创建 #5579

Open
zhuxianglong opened this issue Aug 4, 2022 · 7 comments
Open

many2many Update更新重复创建 #5579

zhuxianglong opened this issue Aug 4, 2022 · 7 comments
Assignees
Labels

Comments

@zhuxianglong
Copy link

GORM Playground Link

go-gorm/playground#1

Description

type CmeQuestion struct {
Id int gorm:"primary_key" json:"id"
QuestionTitle string json:"question_title"
AnalysisContent string json:"analysis_content"
Link string json:"link"
BindCount int json:"bind_count"
Deleted soft_delete.DeletedAt json:"deleted" gorm:"softDelete:flag"
Tag []CmeQuestionTag json:"tag" gorm:"many2many:question_tag;"
Selection []CmeQuestionSelection json:"selection" gorm:"foreignkey:CmeQuestionId"
CreateTime time.Time json:"create_time,omitempty" gorm:"autoCreateTime:true"
UpdateTime time.Time json:"update_time,omitempty" gorm:"autoUpdateTime:true"
DeleteTime gorm.DeletedAt json:"delete_time"
}

dao.Db.Session(&gorm.Session{FullSaveAssociations: true}).Updates(&dao.UpdateModel).Error

@github-actions github-actions bot added the type:question general questions label Aug 4, 2022
@zhuxianglong
Copy link
Author

image
有使用了官方文档的这种方法,也不对,不应该是删除他的中间关系表吗

@zhuxianglong
Copy link
Author

生成的sql竟然是操作user的这个表

@zhuxianglong
Copy link
Author

当前版本使用的是gorm.io/gorm v1.23.8

@zhuxianglong
Copy link
Author

@jinzhu 能看下这个问题吗?我发现这个确实是个bug

@zhuxianglong
Copy link
Author

中间表会不停的创建

@a631807682
Copy link
Member

If you think there is a bug, please create a PR to describe it in the playground.
If you think this is an obvious bug, you should at least provide the simplest reproducible code snippet in your question.
You just copied some code, even the model defined and updated are not the same. No one wants or has the energy to guess what's wrong with you.

@github-actions
Copy link

github-actions bot commented Aug 1, 2023

This issue has been automatically marked as stale because it has been open 360 days with no activity. Remove stale label or comment or this will be closed in 180 days

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

3 participants