{
  "id": "python/sqlalchemy-ambiguous-foreign-key",
  "signature": "sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on relationship User.addresses - there are multiple foreign key paths linking the tables. Specify the 'foreign_keys' argument.",
  "signature_zh": "sqlalchemy.exc.AmbiguousForeignKeysError：无法确定父/子表之间的连接条件——存在多个外键路径链接表。请指定 'foreign_keys' 参数。",
  "regex": "sqlalchemy\\.exc\\.AmbiguousForeignKeysError:\\ Could\\ not\\ determine\\ join\\ condition\\ between\\ parent/child\\ tables\\ on\\ relationship\\ User\\.addresses\\ \\-\\ there\\ are\\ multiple\\ foreign\\ key\\ paths\\ linking\\ the\\ tables\\.\\ Specify\\ the\\ 'foreign_keys'\\ argument\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Multiple foreign keys between two tables without explicit join condition.",
  "root_cause_type": "generic",
  "root_cause_zh": "两个表之间存在多个外键，未指定显式连接条件。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Removing one foreign key constraint from the database.",
      "why_fails": "Destructive and may break data integrity; not necessary.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting primaryjoin with a string that doesn't match columns.",
      "why_fails": "String must be a valid SQL expression; typos cause errors.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Specify 'foreign_keys' argument in relationship.",
      "success_rate": 0.95,
      "how": "class User(Base):\n    __tablename__ = 'users'\n    id = Column(Integer, primary_key=True)\n    addresses = relationship('Address', foreign_keys='Address.user_id')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use primaryjoin explicitly.",
      "success_rate": 0.9,
      "how": "addresses = relationship('Address', primaryjoin='User.id == Address.user_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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}