-
-
Notifications
You must be signed in to change notification settings - Fork 339
Open
Description
I have to use .Table("")
to remove table with tx.
func method1( ){
err := query_moment.Q.Transaction(func(tx *query_moment.Query) error {
err := tx.Moment.Create() // insert into `moment` xxxx
err = method2(tx.Moment.UnderlyingDB())
return err
})
}
func method2( tx *gorm.DB)error{
return query_mgr.Use(tx).Operation.Create() //❌ insert into `moment` xxxx
}
func method1( ){
err := query_moment.Q.Transaction(func(tx *query_moment.Query) error {
err := tx.Moment.Create() // insert into `moment` xxxx
err = method2(tx.Moment.UnderlyingDB().Table(""))//⚠️
return err
})
}
func method2( tx *gorm.DB)error{
return query_mgr.Use(tx).Operation.Create() //✅ insert into `operation` xxxx
}
provide a better way to pass Transaction
use .Table("")
it's not a good way, looks ugly and easy to forget
Metadata
Metadata
Assignees
Labels
No labels