Gorm 使用Create方法批量插入模型(结构体类型)时,若使用了Upsert 处理冲突,执行后,结构体列表中每个元素自动补充的自增主键的值可能是错的

Gorm 使用Create方法批量插入模型(结构体类型)时,若使用了Upsert 处理冲突,执行后,结构体列表中每个元素自动补充的自增主键的值可能是错的

Gorm 使用Create方法批量插入模型(结构体类型)时,若使用了Upsert 处理冲突,执行后,结构体列表中每个元素自动补充的自增主键的值可能是错的

注:这种情况发生在 批量插入的列表数据中有些记录在数据库中已存在,并且会执行更新操作 参考 https://dev.mysql.com/doc/refman/5.7/en/mysql-affected-rows.html

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 2 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: chenlujjj

碰到同样的问题了, 为啥要关掉呢。。。

Comment From: Tifinity

+1 大哥们是怎么解决的,请教一下