From 229b86f4b53b6258872f71e4e67f1bf2459be420 Mon Sep 17 00:00:00 2001 From: zengkai <627852600@qq.com> Date: Mon, 22 Dec 2025 15:23:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(bunpgd):=20=E4=BF=AE=E5=A4=8D=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E6=9F=A5=E8=AF=A2=E9=92=A9=E5=AD=90=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改了查询钩子的配置方式,确保正确应用日志选项 - 避免了潜在的钩子未生效问题 --- bunpgd/open.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bunpgd/open.go b/bunpgd/open.go index 16f499f..a7c8147 100644 --- a/bunpgd/open.go +++ b/bunpgd/open.go @@ -39,7 +39,7 @@ func WithSLog(opts ...bunslog.Option) bun.DBOption { bunslog.WithSlowQueryThreshold(3 * time.Second), } } - return func(db *bun.DB) { db.WithQueryHook(bunslog.NewQueryHook(opts...)) } + return func(db *bun.DB) { *db = *db.WithQueryHook(bunslog.NewQueryHook(opts...)) } } func WithCreateTable(ctx context.Context, cancel context.CancelCauseFunc, model ...any) bun.DBOption { From 6aa92bbfeadc5a81be4e208589747f352d545c26 Mon Sep 17 00:00:00 2001 From: zengkai <627852600@qq.com> Date: Mon, 22 Dec 2025 16:34:25 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(bunpgd):=20=E4=BF=AE=E5=A4=8D=20WithOTE?= =?UTF-8?q?L=20=E5=87=BD=E6=95=B0=E4=B8=AD=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=9F=A5=E8=AF=A2=E9=92=A9=E5=AD=90=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更正了 WithOTEL 函数内对数据库实例的应用逻辑 - 确保查询钩子正确地附加到数据库实例上 - 避免了可能的指针操作错误,提升代码健壮性 --- bunpgd/open.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bunpgd/open.go b/bunpgd/open.go index a7c8147..749c24b 100644 --- a/bunpgd/open.go +++ b/bunpgd/open.go @@ -27,7 +27,7 @@ func WithConnMaxIdleTime(d time.Duration) bun.DBOption { } func WithOTEL(option ...bunotel.Option) bun.DBOption { - return func(db *bun.DB) { db.WithQueryHook(bunotel.NewQueryHook(option...)) } + return func(db *bun.DB) { *db = *db.WithQueryHook(bunotel.NewQueryHook(option...)) } } func WithSLog(opts ...bunslog.Option) bun.DBOption {