mybasemodel: type BaseModel struct { Id uint gorm:"primarykey" CreatedAt time.Time gorm:"column:add_time" UpdatedAt time.Time gorm:"column:update_time" DeletedAt time.Time gorm:"column:deleted_time" IsDeleted bool } function: func (c BaseModel) BeforeDelete(tx gorm.DB) (err error) { if err := tx.Model(c).Updates(map[string]interface{}{ "is_deleted": true, "deleted_time": time.Now(), }).Error; err != nil { return err } return nil } func SoftDeleteCallback(db gorm.DB) { if db.Statement.Schema != nil { if field, ok := db.Statement.Schema.FieldsByName["is_deleted"]; ok { db.Statement.SetColumn(field.DBName, true) return } } } DB.Callback().Delete().Before("gorm:delete").Register("soft_delete", SoftDeleteCallback)

func TestDelete(t *testing.T) { job := do.JobLogDo{ Id: 10300882509824, } orm.DB.Delete(&job) }

results of execution: UPDATE base_models SET deleted_time='2023-09-20 00:28:31.058',is_deleted=true,update_time='2023-09-20 00:28:31.058'

I'm not using the current struct's table here, and my struct implements the TableName method. However, it's still using the table name of the parent model.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: saeidee

The description doesn't have proper example please submit a playground PR.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking