# sql: 转换参数 $1 类型：不支持的类型 []byte，字节切片

- **ID:** `go/database-sql-unsupported-type`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

数据库驱动不支持作为查询参数传递的特定 Go 类型，例如未正确转换的 []byte。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.17 | active | — | — |
| 1.21 | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Convert []byte to a driver.Valuer: type ByteArray []byte; func (b ByteArray) Value() (driver.Value, error) { return []byte(b), nil }
   ```
2. **** (80% 成功率)
   ```
   Use a driver-specific type like pq.ByteaArray for PostgreSQL: args = append(args, pq.ByteaArray(data))
   ```

## 无效尝试

- **** — May not preserve binary data and can cause encoding issues. (60% 失败率)
- **** — Doesn't solve the underlying type mismatch. (80% 失败率)
