add panic test

This commit is contained in:
leiyuqing 2022-04-03 11:24:45 +08:00
parent 5d0bc6e309
commit 46387c7b55
2 changed files with 8 additions and 0 deletions

View File

@ -763,3 +763,7 @@ func TestUpdateReturning(t *testing.T) {
t.Errorf("failed to return updated age column") t.Errorf("failed to return updated age column")
} }
} }
func TestAfterCreateWithPanic(t *testing.T) {
DB.Model(User{}).Where("name=?", "update-1").Update("name", "update-1-1")
}

View File

@ -31,6 +31,10 @@ type User struct {
Active bool Active bool
} }
func (u *User) AfterCreate(tx *gorm.DB) error {
return nil
}
type Account struct { type Account struct {
gorm.Model gorm.Model
UserID sql.NullInt64 UserID sql.NullInt64