support DB.BeginTx of golang 1.8

Signed-off-by: Penghui Liao <liaoishere@gmail.com>
This commit is contained in:
Penghui Liao
2018-05-04 16:38:03 +08:00
parent 0dff771707
commit 443c77b303
4 changed files with 96 additions and 4 deletions

View File

@@ -15,6 +15,7 @@
package orm
import (
"context"
"database/sql"
"fmt"
"io"
@@ -150,6 +151,13 @@ func (d *dbQueryLog) Begin() (*sql.Tx, error) {
return tx, err
}
func (d *dbQueryLog) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error) {
a := time.Now()
tx, err := d.db.(txer).BeginTx(ctx, opts)
debugLogQueies(d.alias, "db.BeginTx", "START TRANSACTION", a, err)
return tx, err
}
func (d *dbQueryLog) Commit() error {
a := time.Now()
err := d.db.(txEnder).Commit()