@@ -2,8 +2,6 @@ package db
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
- "time"
7
5
8
6
"github.com/domonda/go-sqldb"
9
7
)
@@ -48,21 +46,9 @@ func ContextWithConn(ctx context.Context, conn sqldb.Connection) context.Context
48
46
return context .WithValue (ctx , & globalConnCtxKey , conn )
49
47
}
50
48
51
- // ContextWithoutCancel returns a new context that inherits
52
- // all values from parent, but not its cancellation state.
53
- func ContextWithoutCancel (parent context.Context ) context.Context {
54
- if _ , ok := parent .(contextWithoutCancel ); ok {
55
- return parent
56
- }
57
- return contextWithoutCancel {parent }
58
- }
59
-
60
- type contextWithoutCancel struct {
61
- parent context.Context
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 ()
62
54
}
63
-
64
- func (contextWithoutCancel ) Deadline () (time.Time , bool ) { return time.Time {}, false }
65
- func (contextWithoutCancel ) Done () <- chan struct {} { return nil }
66
- func (contextWithoutCancel ) Err () error { return nil }
67
- func (c contextWithoutCancel ) Value (key any ) any { return c .parent .Value (key ) }
68
- func (c contextWithoutCancel ) String () string { return fmt .Sprintf ("%s.WithoutCancel" , c .parent ) }
0 commit comments