Skip to content

Commit baaff00

Browse files
committed
fix
1 parent 080429f commit baaff00

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/hooks_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,15 @@ func TestBeforeUpdateWithStructColumn(t *testing.T) {
638638
t.Fatalf("create struct failed: %v", err)
639639
}
640640

641-
sql := DB.ToSQL(func(tx *gorm.DB) *gorm.DB {
642-
return tx.Model(&su).Update("name", "demoManito")
643-
})
644-
if sql != "UPDATE `struct_updates` SET `name`='demoManito',`version`=2 WHERE `id` = 1" {
645-
t.Fatalf("invalid sql: %v", sql)
641+
err = DB.Model(&su).Update("name", "demoManito").Error
642+
if err != nil {
643+
t.Fatalf("update struct failed: %v", err)
644+
}
645+
if su.Version != 2 {
646+
t.Fatalf("update version failed: %v", su.Version)
647+
}
648+
err = DB.Find(&su, "id = ?", 1).Error
649+
if err != nil {
650+
t.Fatalf("find struct failed: %v", err)
646651
}
647652
}

0 commit comments

Comments
 (0)