https://github.com/go-gorm/playground/pull/154
value := &Test{Value: "foo"}
db.Model(Test{}).Create(&value)
value.Value = "bar"
db.Model(Test{}).Save(&value)
--> Save: WHERE condition required
Bug, or no longer supported to use Model?
db.Save(&value) --> OK
@jinzhu The condition is generated without the .Model(),but you don't require a .Where() before a .Save() so I don't understand how this isn't a bug.
@jinzhu
db.Debug().Model(Test{}).Save(&test)
Outputs
[0.284ms] [rows:0] UPDATE `tests` SET `id`=1,`value`="test"
db.Debug().Save(&test)
Outputs
[0.525ms] [rows:0] UPDATE `tests` SET `value`="test" WHERE `id` = 1
Having same problem, wonder if there is a way to do gorm v1-like Save, which is an upsert function.
Most helpful comment
@jinzhu The condition is generated without the .Model(),but you don't require a .Where() before a .Save() so I don't understand how this isn't a bug.