mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
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:
committed by
Facebook Github Bot
parent
d2fb1b5548
commit
1bf83dd65f
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user