{
  "id": "go/database-sql-rows-scan-type",
  "signature": "sql: Scan error on column index 1: converting driver.Value type string (\"hello\") to a int: invalid syntax",
  "signature_zh": "sql: 第 1 列扫描错误：将 driver.Value 类型 string (\"hello\") 转换为 int：无效语法",
  "regex": "sql:\\ Scan\\ error\\ on\\ column\\ index\\ 1:\\ converting\\ driver\\.Value\\ type\\ string\\ \\(\"hello\"\\)\\ to\\ a\\ int:\\ invalid\\ syntax",
  "domain": "go",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "The database returned a value that cannot be converted to the target Go type during Scan, often due to schema mismatch.",
  "root_cause_type": "generic",
  "root_cause_zh": "数据库返回的值无法在 Scan 期间转换为目标 Go 类型，通常是由于架构不匹配。",
  "versions": [
    {
      "version": "1.16",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.20",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "May not be feasible in production or requires migration.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leads to incorrect data handling and potential bugs.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Scan into an intermediate type and convert: var tmp string; rows.Scan(&tmp); val, _ := strconv.Atoi(tmp)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use sql.NullInt64 to handle nullable/invalid values: var n sql.NullInt64; rows.Scan(&n); if n.Valid { val := n.Int64 }",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}