mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 03:40:54 +00:00
do not judge tx status in txOrm
This commit is contained in:
parent
aefe21b63a
commit
4aad313de7
@ -530,7 +530,6 @@ func (o *orm) BeginWithCtxAndOpts(ctx context.Context, opts *sql.TxOptions) (TxO
|
||||
alias: o.alias,
|
||||
db: &TxDB{tx: tx},
|
||||
},
|
||||
isClosed: false,
|
||||
}
|
||||
|
||||
var taskTxOrm TxOrmer = _txOrm
|
||||
@ -577,33 +576,15 @@ func (o *orm) DoTxWithCtxAndOpts(ctx context.Context, opts *sql.TxOptions, task
|
||||
|
||||
type txOrm struct {
|
||||
ormBase
|
||||
isClosed bool
|
||||
closeMutex sync.Mutex
|
||||
}
|
||||
|
||||
var _ TxOrmer = new(txOrm)
|
||||
|
||||
func (t *txOrm) Commit() error {
|
||||
t.closeMutex.Lock()
|
||||
defer t.closeMutex.Unlock()
|
||||
|
||||
if t.isClosed {
|
||||
return ErrTxDone
|
||||
}
|
||||
t.isClosed = true
|
||||
|
||||
return t.db.(txEnder).Commit()
|
||||
}
|
||||
|
||||
func (t *txOrm) Rollback() error {
|
||||
t.closeMutex.Lock()
|
||||
defer t.closeMutex.Unlock()
|
||||
|
||||
if t.isClosed {
|
||||
return ErrTxDone
|
||||
}
|
||||
t.isClosed = true
|
||||
|
||||
return t.db.(txEnder).Rollback()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user