提交 4aad313d 编写于 作者: J jianzhiyao

do not judge tx status in txOrm

上级 aefe21b6
......@@ -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()
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册