dialect/sql: add BeginTx for sql driver

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/193

Reviewed By: dlvhdr

Differential Revision: D18685934

fbshipit-source-id: abc4bf0b14ece3827bc20ecb864e7ca0594c2759
This commit is contained in:
Ariel Mashraki
2019-11-25 07:23:10 -08:00
committed by Facebook Github Bot
parent d2fb1b5548
commit 1bf83dd65f

View File

@@ -51,7 +51,12 @@ func (d Driver) Dialect() string {
// Tx starts and returns a transaction.
func (d *Driver) Tx(ctx context.Context) (dialect.Tx, error) {
tx, err := d.ExecQuerier.(*sql.DB).BeginTx(ctx, &sql.TxOptions{})
return d.BeginTx(ctx, &sql.TxOptions{})
}
// BeginTx starts a transaction with options.
func (d *Driver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error) {
tx, err := d.ExecQuerier.(*sql.DB).BeginTx(ctx, opts)
if err != nil {
return nil, err
}