2
0

Commit and Rollback take context

Remove Ex versions.
This commit is contained in:
Jack Christensen
2019-04-10 12:22:12 -05:00
parent 7718ee6207
commit 54c6ddc2f0
9 changed files with 32 additions and 45 deletions
+4 -4
View File
@@ -12,8 +12,8 @@ type Tx struct {
c *Conn
}
func (tx *Tx) Commit() error {
err := tx.t.Commit()
func (tx *Tx) Commit(ctx context.Context) error {
err := tx.t.Commit(ctx)
if tx.c != nil {
tx.c.Release()
tx.c = nil
@@ -21,8 +21,8 @@ func (tx *Tx) Commit() error {
return err
}
func (tx *Tx) Rollback() error {
err := tx.t.Rollback()
func (tx *Tx) Rollback(ctx context.Context) error {
err := tx.t.Rollback(ctx)
if tx.c != nil {
tx.c.Release()
tx.c = nil
+3 -3
View File
@@ -16,7 +16,7 @@ func TestTxExec(t *testing.T) {
tx, err := pool.Begin()
require.NoError(t, err)
defer tx.Rollback()
defer tx.Rollback(context.Background())
testExec(t, tx)
}
@@ -28,7 +28,7 @@ func TestTxQuery(t *testing.T) {
tx, err := pool.Begin()
require.NoError(t, err)
defer tx.Rollback()
defer tx.Rollback(context.Background())
testQuery(t, tx)
}
@@ -40,7 +40,7 @@ func TestTxQueryRow(t *testing.T) {
tx, err := pool.Begin()
require.NoError(t, err)
defer tx.Rollback()
defer tx.Rollback(context.Background())
testQueryRow(t, tx)
}