Skip to content

Commit be31368

Browse files
committed
added db.IsTransaction
1 parent 7c88ca5 commit be31368

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

db/conn.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,10 @@ func ConnDefault(ctx context.Context, defaultConn sqldb.Connection) sqldb.Connec
4545
func ContextWithConn(ctx context.Context, conn sqldb.Connection) context.Context {
4646
return context.WithValue(ctx, &globalConnCtxKey, conn)
4747
}
48+
49+
// IsTransaction indicates if the connection from the context,
50+
// or the default connection if the context has none,
51+
// is a transaction.
52+
func IsTransaction(ctx context.Context) bool {
53+
return Conn(ctx).IsTransaction()
54+
}

0 commit comments

Comments
 (0)