need apply scopes before invoke transaction begin hooks
This commit is contained in:
parent
3b79a192cd
commit
bc340b7abe
@ -79,6 +79,15 @@ func (cs *callbacks) Transaction() *processor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *processor) Begin(tx *DB, opt *sql.TxOptions) *DB {
|
func (p *processor) Begin(tx *DB, opt *sql.TxOptions) *DB {
|
||||||
|
// call scopes
|
||||||
|
for len(tx.Statement.scopes) > 0 {
|
||||||
|
scopes := tx.Statement.scopes
|
||||||
|
tx.Statement.scopes = nil
|
||||||
|
for _, scope := range scopes {
|
||||||
|
tx = scope(tx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tx.InstanceSet("gorm:transaction_options", opt)
|
tx.InstanceSet("gorm:transaction_options", opt)
|
||||||
|
|
||||||
for _, f := range p.fns {
|
for _, f := range p.fns {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user