From 4aad313de7fbf4da9fd74e89d1e722f2702a29b2 Mon Sep 17 00:00:00 2001 From: jianzhiyao Date: Mon, 20 Jul 2020 17:34:58 +0800 Subject: [PATCH] do not judge tx status in txOrm --- pkg/orm/orm.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pkg/orm/orm.go b/pkg/orm/orm.go index 24632270..8ef761f4 100644 --- a/pkg/orm/orm.go +++ b/pkg/orm/orm.go @@ -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() }