Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
demoManito committed Aug 26, 2024
1 parent 671e7db commit e461e9f
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions callbacks/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ func SetupUpdateReflectValue(db *gorm.DB) {
func BeforeUpdate(db *gorm.DB) {
if db.Error == nil && db.Statement.Schema != nil && !db.Statement.SkipHooks && (db.Statement.Schema.BeforeSave || db.Statement.Schema.BeforeUpdate) {
callMethod(db, func(value interface{}, tx *gorm.DB) (called bool) {
rv := reflect.ValueOf(value)
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
// save a copy before executing the hook so that can find out which fields were modified after the hook is executed.
rv := reflect.Indirect(reflect.ValueOf(value))
rvClone := reflect.New(rv.Type()).Elem()
rvClone.Set(rv)

Expand Down

0 comments on commit e461e9f

Please sign in to comment.