-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Save() 会覆盖软删除 #4894
Comments
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 |
https://gorm.cn/zh_CN/docs/update.html#%E4%BF%9D%E5%AD%98%E6%89%80%E6%9C%89%E5%AD%97%E6%AE%B5 |
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 |
看了看 Save() 的行为,的确会在不存在的情况下创建。但是我说的问题依旧存在。 软删除的行为定义下,数据被软删除之后,ORM 应当认定为不存在此条数据,Save() 的行为应该是
但目前的行为是
如果 Save() 能在不覆盖 DeletedAt 的情况下更新数据倒是符合需求,但是不符合 Save() 的定义了。 |
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 |
@Aoang already fix, thank you. |
描述
问题比较简单,数据库中某条记录被软删除,如果使用 Save() 保存数据,会恢复软删除。
场景出现在多协程中,某个协程删除了一条记录,另一个协程在没有使用事务的情况下(执行时间比较长)保存数据。
按照行为来定义的话,Save() 应该会报错,而不是直接保存。
Code
逻辑
预期:报错,提示数据不存在
结果:数据保存成功,且软删除无了
The text was updated successfully, but these errors were encountered: