go
data_error
ai_generated
true
sql: Scan error on column index 2: converting NULL to string is unsupported
ID: go/sql-nil-value-scan
80%Fix Rate
88%Confidence
0Evidence
2024-07-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.13 | active | — | — | — |
Root Cause
数据库字段为NULL,但Scan目标类型不支持NULL
generic中文
数据库字段为NULL,但Scan目标类型不支持NULL
Workarounds
-
95% success
使用sql.NullString类型
-
85% success
在SQL查询中使用COALESCE
Dead Ends
Common approaches that don't work:
-
90% fail
NULL仍然无法转换为string
-
60% fail
数据丢失