{
  "id": "go/database-scan-null-field",
  "signature": "sql: Scan error on column index 3: converting NULL to string is unsupported",
  "signature_zh": "SQL 扫描错误：列索引 3 上无法将 NULL 转换为字符串",
  "regex": "sql: Scan error on column index \\d+: converting NULL to .+ is unsupported",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Scanning a NULL database value into a non-pointer Go type (e.g., string instead of *string or sql.NullString).",
  "root_cause_type": "generic",
  "root_cause_zh": "将数据库中的 NULL 值扫描到非指针的 Go 类型（例如，使用 string 而不是 *string 或 sql.NullString）。",
  "versions": [
    {
      "version": "Go 1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Go 1.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This masks the data issue and can lead to incorrect business logic if NULL has semantic meaning.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Pollutes the data and may break other queries or reports.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use sql.NullString or *string for nullable columns, then check .Valid before use",
      "success_rate": 0.95,
      "how": "Use sql.NullString or *string for nullable columns, then check .Valid before use",
      "condition": "",
      "sources": []
    },
    {
      "action": "Define custom struct fields as pointers to handle NULLs",
      "success_rate": 0.9,
      "how": "Define custom struct fields as pointers to handle NULLs",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "对可空列使用 sql.NullString 或 *string，并在使用前检查 .Valid",
    "将自定义结构体字段定义为指针以处理 NULL"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://pkg.go.dev/database/sql#NullString",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-03-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}