I tried this, but not got the expectation.

func (cars *CARS) AfterCreate(tx *gorm.DB) (err error) {
    fmt.Println("hook after =>", tx.Statement.SQL.String())
    return
}

/*
Insert ...
*/
func (cars *CARS) Insert(ctx context.Context) error {
    tx := db.Create(cars)
    fmt.Println("did ===>", tx.Statement.SQL.String())
    return tx.Error
}

output

hook after => INSERT INTO `cars` (`name`) VALUES (?)
did ===>

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 2 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: li-jin-gou

get the SQL before execution (use plugin) or look this doc https://pkg.go.dev/gorm.io/gorm#DB.ToSQL