Closed 42thcoder closed 2 years ago
有些字段是不存在并发冲突风险的, 开发者会直接使用 map 来更新.
result = db.Model(&account).Updates(map[string]interface{}{"video_profit": account.VideoProfit})
但是目前的机制, 会自动增加 version 到 where 中导致更新失败
希望提供额外的选项, 例如说 IgnoreLockVersion, 可以在使用 map 或者 struct 更新时, 忽略乐观锁的限制, 例如 where 中不再与偶 version 的判断
目前有两个方案可以实现该需求
方案一相信不用解释,为零值的时候自然也没办法加version条件。 方案二是通过skipHooks跳过了添加version条件逻辑。但我暂时没有遇到类似的场景,我疑问是大家在开发中这种场景多吗?如果这样子实现是否会让使用者产生疑问
For the new proposal, see #15
场景
有些字段是不存在并发冲突风险的, 开发者会直接使用 map 来更新.
result = db.Model(&account).Updates(map[string]interface{}{"video_profit": account.VideoProfit})
但是目前的机制, 会自动增加 version 到 where 中导致更新失败
诉求
希望提供额外的选项, 例如说 IgnoreLockVersion, 可以在使用 map 或者 struct 更新时, 忽略乐观锁的限制, 例如 where 中不再与偶 version 的判断