Skip to content

Commit

Permalink
added db.IsTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Sep 29, 2023
1 parent 7c88ca5 commit be31368
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ func ConnDefault(ctx context.Context, defaultConn sqldb.Connection) sqldb.Connec
func ContextWithConn(ctx context.Context, conn sqldb.Connection) context.Context {
return context.WithValue(ctx, &globalConnCtxKey, conn)
}

// IsTransaction indicates if the connection from the context,
// or the default connection if the context has none,
// is a transaction.
func IsTransaction(ctx context.Context) bool {
return Conn(ctx).IsTransaction()
}

0 comments on commit be31368

Please sign in to comment.