{
  "id": "android/room-query-parameter-mismatch",
  "signature": "android.database.sqlite.SQLiteException: near \"?\": syntax error (code 1): , while compiling: SELECT * FROM users WHERE id = ? AND name = ?",
  "signature_zh": "android.database.sqlite.SQLiteException: 语法错误 near \"?\": (code 1): , 编译时: SELECT * FROM users WHERE id = ? AND name = ?",
  "regex": "android\\.database\\.sqlite\\.SQLiteException: near \"\\?\": syntax error \\(code 1\\)",
  "domain": "android",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The number of parameters in a Room @Query does not match the number of method arguments, causing a SQL syntax error.",
  "root_cause_type": "generic",
  "root_cause_zh": "Room @Query 中的参数数量与方法参数数量不匹配，导致 SQL 语法错误。",
  "versions": [
    {
      "version": "Room 2.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Room 2.6.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The SQL query still has fewer placeholders than arguments, causing a mismatch error.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This introduces SQL injection risk and does not fix the parameter count issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the number of '?' placeholders in the SQL query matches the number of method parameters. Example: If method is 'fun getUser(id: Int, name: String): User?', the query should be 'SELECT * FROM users WHERE id = ? AND name = ?'.",
      "success_rate": 0.95,
      "how": "Ensure the number of '?' placeholders in the SQL query matches the number of method parameters. Example: If method is 'fun getUser(id: Int, name: String): User?', the query should be 'SELECT * FROM users WHERE id = ? AND name = ?'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use named bind parameters with ':paramName' syntax for clarity and to avoid count mismatches. Example: 'SELECT * FROM users WHERE id = :id AND name = :name'.",
      "success_rate": 0.9,
      "how": "Use named bind parameters with ':paramName' syntax for clarity and to avoid count mismatches. Example: 'SELECT * FROM users WHERE id = :id AND name = :name'.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Run Room's annotation processor (kapt or ksp) to generate validation errors at compile time that catch parameter mismatches.",
      "success_rate": 0.85,
      "how": "Run Room's annotation processor (kapt or ksp) to generate validation errors at compile time that catch parameter mismatches.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保 SQL 查询中的 '?' 占位符数量与方法参数数量匹配。例如：如果方法是 'fun getUser(id: Int, name: String): User?'，查询应为 'SELECT * FROM users WHERE id = ? AND name = ?'。",
    "使用命名绑定参数语法 ':paramName' 以提高清晰度并避免计数不匹配。例如：'SELECT * FROM users WHERE id = :id AND name = :name'。",
    "运行 Room 的注解处理器（kapt 或 ksp）以在编译时生成验证错误，捕获参数不匹配问题。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://developer.android.com/training/data-storage/room/accessing-data#query",
  "official_doc_section": null,
  "error_code": "1",
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-02-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}