refactor(services): 统一数据库插件的DBWrapper

4个数据库插件(MySQL、PostgreSQL、MSSQL、Oracle)都有相同的sql.DB包装代码,
合并为通用的SQLDBWrapper,减少重复。
This commit is contained in:
ZacharyZcR
2026-01-21 22:59:52 +08:00
parent df724195e2
commit 8260bee61c
5 changed files with 19 additions and 41 deletions
+1 -10
View File
@@ -104,21 +104,12 @@ func (p *PostgreSQLPlugin) doPostgreSQLAuth(ctx context.Context, info *common.Ho
return &AuthResult{
Success: true,
Conn: &pgDBWrapper{db},
Conn: &SQLDBWrapper{db},
ErrorType: ErrorTypeUnknown,
Error: nil,
}
}
// pgDBWrapper 包装 sql.DB 以实现 io.Closer
type pgDBWrapper struct {
*sql.DB
}
func (w *pgDBWrapper) Close() error {
return w.DB.Close()
}
// classifyPostgreSQLErrorType PostgreSQL错误分类
func classifyPostgreSQLErrorType(err error) ErrorType {
if err == nil {