From caafb63085b079baa6d5657bb04be74d555007f4 Mon Sep 17 00:00:00 2001 From: itxaiohanglover <1531137510@qq.com> Date: Thu, 2 Jul 2026 01:02:36 +0800 Subject: [PATCH] fix: add Conn and *Conn to mapperFor and isUnsafe type switches Conn was missing from the type switches in mapperFor() and isUnsafe(), causing custom Mapper and unsafe flag to not propagate when creating Stmts from *sqlx.Conn. Fixes #975 --- sqlx.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sqlx.go b/sqlx.go index 8259a4feb..95f4669c4 100644 --- a/sqlx.go +++ b/sqlx.go @@ -136,6 +136,10 @@ func isUnsafe(i interface{}) bool { return v.unsafe case *Tx: return v.unsafe + case Conn: + return v.unsafe + case *Conn: + return v.unsafe case sql.Rows, *sql.Rows: return false default: @@ -153,6 +157,10 @@ func mapperFor(i interface{}) *reflectx.Mapper { return i.Mapper case *Tx: return i.Mapper + case Conn: + return i.Mapper + case *Conn: + return i.Mapper default: return mapper() }