{
  "id": "go/database-sql-null-value",
  "signature": "sql: Scan error on column index 2: converting NULL to string is unsupported",
  "signature_zh": "sql：第2列扫描错误：不支持将NULL转换为字符串",
  "regex": "sql:\\ Scan\\ error\\ on\\ column\\ index\\ 2:\\ converting\\ NULL\\ to\\ string\\ is\\ unsupported",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Scanning a NULL database column into a non-nullable Go type (e.g., string) without using sql.NullString.",
  "root_cause_type": "generic",
  "root_cause_zh": "将数据库中的NULL列扫描到不可为空的Go类型（如string）中，而未使用sql.NullString。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.19",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "NULL is not the same as an empty string and can lead to data loss.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Go does not allow direct casting of NULL to string.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "var s sql.NullString\nif err := rows.Scan(&s); err != nil {\n    // handle error\n}\nif s.Valid {\n    fmt.Println(s.String)\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.8,
      "how": "Use COALESCE in SQL query to convert NULL to default value.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}