]> 127.0.0.1 Git - part/.git/commitdiff
1 v0.28.20240422182232
authorqydysky <qydysky@foxmail.com>
Mon, 22 Apr 2024 18:17:45 +0000 (18:17 +0000)
committerqydysky <qydysky@foxmail.com>
Mon, 22 Apr 2024 18:17:45 +0000 (18:17 +0000)
log/Log.go

index 3ee54376238ea54c6eae8f1148db9fcb79242e5e..488a3d6fb98bcb02ae2588a08a604a3bbad6415b 100644 (file)
@@ -1,6 +1,7 @@
 package part
 
 import (
+       "context"
        "database/sql"
        "fmt"
        "io"
@@ -73,7 +74,12 @@ func New(c Config) (o *Log_interface) {
                        }
                }
                if msg.DBConn != nil && msg.DBInsert != `` {
-                       sqlTx := psql.BeginTx[any](msg.DBConn, pctx.GenTOCtx(o.To))
+                       var sqlTx *psql.SqlTx[any]
+                       if o.To == 0 {
+                               sqlTx = psql.BeginTx[any](msg.DBConn, context.Background())
+                       } else {
+                               sqlTx = psql.BeginTx[any](msg.DBConn, pctx.GenTOCtx(o.To))
+                       }
                        sqlTx.SimpleDo(
                                msg.DBInsert,
                                strings.TrimSpace(msg.Prefix),