@@ -12,7 +12,7 @@ type Querier interface {
12
12
Conn () * sql.DB
13
13
ExecContext (ctx context.Context , query string , args ... any ) (sql.Result , error )
14
14
QueryContext (ctx context.Context , query string , args ... any ) (* sql.Rows , error )
15
- BeginTx (ctx context.Context , opts * sql. TxOptions ) (QuerierTx , error )
15
+ BeginTx (ctx context.Context , write bool ) (QuerierTx , error )
16
16
}
17
17
18
18
type QuerierTx interface {
@@ -34,6 +34,10 @@ func New(dbPath string, debug bool) (Querier, error) {
34
34
return nil , err
35
35
}
36
36
37
+ if err := dummyCreate (db ); err != nil {
38
+ return nil , err
39
+ }
40
+
37
41
if debug {
38
42
return DebugDB {DB : db }, nil
39
43
}
@@ -45,8 +49,8 @@ type DB struct {
45
49
* sql.DB
46
50
}
47
51
48
- func (db DB ) BeginTx (ctx context.Context , opts * sql. TxOptions ) (QuerierTx , error ) {
49
- return db .DB . BeginTx ( ctx , opts )
52
+ func (db DB ) BeginTx (ctx context.Context , write bool ) (QuerierTx , error ) {
53
+ return dummyBeginTx ( ctx , db .DB , write )
50
54
}
51
55
52
56
func (db DB ) Conn () * sql.DB {
@@ -97,20 +101,16 @@ func (tx DebugTx) QueryContext(ctx context.Context, query string, args ...any) (
97
101
return tx .Tx .QueryContext (ctx , query , args ... )
98
102
}
99
103
100
- func (db DebugDB ) BeginTx (ctx context.Context , opts * sql. TxOptions ) (QuerierTx , error ) {
104
+ func (db DebugDB ) BeginTx (ctx context.Context , write bool ) (QuerierTx , error ) {
101
105
log .Debug ().
102
106
Msg ("BeginTx (Tx)" )
103
- tx , err := db .DB . BeginTx ( ctx , opts )
107
+ tx , err := dummyBeginTx ( ctx , db .DB , write )
104
108
if err != nil {
105
109
return DebugTx {}, err
106
110
}
107
111
return DebugTx {Tx : tx }, nil
108
112
}
109
113
110
- type DebugTx struct {
111
- * sql.Tx
112
- }
113
-
114
114
func (tx DebugTx ) Commit () error {
115
115
log .Debug ().
116
116
Str ("func" , "Commit (Tx)" ).
@@ -124,3 +124,7 @@ func (tx DebugTx) Rollback() error {
124
124
Msg ("" )
125
125
return tx .Tx .Rollback ()
126
126
}
127
+
128
+ type DebugTx struct {
129
+ * sql.Tx
130
+ }
0 commit comments