return ciCtx.BeginTx(ctx, dopts)
}
- if ctx.Done() == context.Background().Done() {
- return ci.Begin()
- }
-
if opts != nil {
// Check the transaction level. If the transaction level is non-default
// then return an error here as the BeginTx driver value is not supported.
}
}
+ if ctx.Done() == context.Background().Done() {
+ return ci.Begin()
+ }
+
txi, err := ci.Begin()
if err == nil {
select {
waitForFree(t, db, 5*time.Second, 0)
}
+// TestUnsupportedOptions checks that the database fails when a driver that
+// doesn't implement ConnBeginTx is used with non-default options and an
+// un-cancellable context.
+func TestUnsupportedOptions(t *testing.T) {
+ db := newTestDB(t, "people")
+ defer closeDB(t, db)
+ _, err := db.BeginTx(context.Background(), &TxOptions{
+ Isolation: LevelSerializable, ReadOnly: true,
+ })
+ if err == nil {
+ t.Fatal("expected error when using unsupported options, got nil")
+ }
+}
+
func TestMultiResultSetQuery(t *testing.T) {
db := newTestDB(t, "people")
defer closeDB(t, db)