From 1aa1846afbf091c9b8bebb53340eff568a9b87bd Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 23 Jul 2017 09:52:08 +0800 Subject: [PATCH] Revert "support reuse session to transaction (#650)" (#651) This reverts commit c412be236502ca71315dd61dbd324f3706010f0c. --- session_tx.go | 2 -- session_tx_test.go | 31 ------------------------------- 2 files changed, 33 deletions(-) diff --git a/session_tx.go b/session_tx.go index c8f0777c..302bc104 100644 --- a/session_tx.go +++ b/session_tx.go @@ -24,7 +24,6 @@ func (session *Session) Rollback() error { if !session.IsAutoCommit && !session.IsCommitedOrRollbacked { session.saveLastSQL(session.Engine.dialect.RollBackStr()) session.IsCommitedOrRollbacked = true - session.IsAutoCommit = true return session.Tx.Rollback() } return nil @@ -35,7 +34,6 @@ func (session *Session) Commit() error { if !session.IsAutoCommit && !session.IsCommitedOrRollbacked { session.saveLastSQL("COMMIT") session.IsCommitedOrRollbacked = true - session.IsAutoCommit = true var err error if err = session.Tx.Commit(); err == nil { // handle processors after tx committed diff --git a/session_tx_test.go b/session_tx_test.go index adb11c66..3e71bb40 100644 --- a/session_tx_test.go +++ b/session_tx_test.go @@ -190,34 +190,3 @@ func TestCombineTransactionSameMapper(t *testing.T) { panic(err) } } - -func TestReuseTransaction(t *testing.T) { - assert.NoError(t, prepareEngine()) - sess := testEngine.NewSession() - defer sess.Close() - - type ReuseTx struct { - Id int64 - Name string - } - - assertSync(t, new(ReuseTx)) - - records := []ReuseTx{ - { - Name: "1", - }, - { - Name: "3", - }, - { - Name: "2", - }, - } - for _, r := range records { - assert.NoError(t, sess.Begin()) - _, err := sess.Insert(&r) - assert.NoError(t, err) - assert.NoError(t, sess.Commit()) - } -}