{
  "id": "python/flask-sqlalchemy-ambiguous-foreign-key",
  "signature": "sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship User.posts - there are multiple foreign key paths linking the tables.",
  "signature_zh": "sqlalchemy.exc.AmbiguousForeignKeysError: 无法确定 User.posts 关系上父/子表之间的连接条件 - 存在多条连接两表的外键路径。",
  "regex": "sqlalchemy\\.exc\\.AmbiguousForeignKeysError:\\ Could\\ not\\ determine\\ join\\ condition\\ between\\ parent/child\\ tables\\ on\\ relationship\\ User\\.posts\\ \\-\\ there\\ are\\ multiple\\ foreign\\ key\\ paths\\ linking\\ the\\ tables\\.",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Multiple foreign keys between two tables leave SQLAlchemy unable to infer which FK the relationship uses.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个表之间存在多个外键，导致 SQLAlchemy 无法推断关系使用哪个外键。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Breaks the data model that intentionally needs both.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Does not resolve join ambiguity.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "posts = relationship('Post', foreign_keys='Post.author_id')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "posts = relationship('Post', primaryjoin='User.id == Post.author_id')",
      "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.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}