{
  "id": "python/sqlalchemy-no-referenced-table",
  "signature": "sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'table.column' could not find table 'other_table' with which to generate a foreign key to target column 'id'",
  "signature_zh": "SQLAlchemy 无引用表错误：与列 'table.column' 关联的外键找不到表 'other_table'。",
  "regex": "sqlalchemy\\.exc\\.NoReferencedTableError:\\ Foreign\\ key\\ associated\\ with\\ column\\ 'table\\.column'\\ could\\ not\\ find\\ table\\ 'other_table'\\ with\\ which\\ to\\ generate\\ a\\ foreign\\ key\\ to\\ target\\ column\\ 'id'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "外键引用的表名或模型名拼写错误或未定义。",
  "root_cause_type": "generic",
  "root_cause_zh": "外键引用的表名或模型名拼写错误或未定义。",
  "versions": [
    {
      "version": "1.4.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "2.0.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "尝试在数据库中手动创建表，但 ORM 映射仍然无法找到。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "修改外键列名为其他名称，但未更新关系定义。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "确保引用的表名与 __tablename__ 一致，例如：ForeignKey('other_table.id')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "在模型中定义所有相关表，并确保导入顺序正确。",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}