{
  "id": "python/sqlalchemy-could-not-assemble-mapper",
  "signature": "sqlalchemy.exc.InvalidRequestError: Could not assemble any primary key columns for mapped table 'orders'",
  "signature_zh": "无法为映射表 'orders' 组装任何主键列",
  "regex": "sqlalchemy\\.exc\\.InvalidRequestError:\\ Could\\ not\\ assemble\\ any\\ primary\\ key\\ columns\\ for\\ mapped\\ table\\ 'orders'",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The mapped table lacks a primary key definition, either because no column is marked as primary_key or because the table inherits from a select that doesn't have one.",
  "root_cause_type": "generic",
  "root_cause_zh": "映射表缺少主键定义，可能因为没有列被标记为主键，或表继承自没有主键的 select。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Column is just a regular column; SQLAlchemy still sees no primary key.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Unique constraints don't satisfy the primary key requirement for ORM mapping.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 1.0,
      "how": "class Order(Base):\n    __tablename__ = 'orders'\n    id = Column(Integer, primary_key=True)\n    # other columns",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "class OrderItem(Base):\n    __tablename__ = 'order_items'\n    order_id = Column(Integer, ForeignKey('orders.id'), primary_key=True)\n    product_id = Column(Integer, primary_key=True)",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}