Skip to content

Commit

Permalink
Merge pull request #12 from brucehuang2/master
Browse files Browse the repository at this point in the history
move tx.Unsafe() to after error
  • Loading branch information
fifsky authored Jul 9, 2019
2 parents 7a01d2d + 1facaad commit c1e7870
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ func (w *Wrapper) Select(dest interface{}, query string, args ...interface{}) (e
func (w *Wrapper) Txx(ctx context.Context, fn func(ctx context.Context, tx *sqlx.Tx) error) (err error) {
db := DB(w.database)
tx, err := db.BeginTxx(ctx, nil)
tx = tx.Unsafe()
if err != nil {
return err
}
tx = tx.Unsafe()
defer func() {
if err != nil {
err := tx.Rollback()
Expand All @@ -234,10 +234,10 @@ func (w *Wrapper) Txx(ctx context.Context, fn func(ctx context.Context, tx *sqlx
func (w *Wrapper) Tx(fn func(tx *sqlx.Tx) error) (err error) {
db := DB(w.database)
tx, err := db.Beginx()
tx = tx.Unsafe()
if err != nil {
return err
}
tx = tx.Unsafe()
defer func() {
if err != nil {
err := tx.Rollback()
Expand Down

0 comments on commit c1e7870

Please sign in to comment.