{
  "id": "python/sqlalchemy-stale-data",
  "signature": "sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'users' expected to update 1 row(s); 0 were matched.",
  "signature_zh": "SQLAlchemy ORM 过期数据错误：对用户表的 UPDATE 语句预期更新 1 行，但实际匹配 0 行。",
  "regex": "sqlalchemy\\.orm\\.exc\\.StaleDataError:\\ UPDATE\\ statement\\ on\\ table\\ 'users'\\ expected\\ to\\ update\\ 1\\ row\\(s\\);\\ 0\\ were\\ matched\\.",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "对象已被其他事务删除或修改，导致 UPDATE 操作影响行数为 0。",
  "root_cause_type": "generic",
  "root_cause_zh": "对象已被其他事务删除或修改，导致 UPDATE 操作影响行数为 0。",
  "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": "忽略错误并继续，但数据状态不一致。",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "强制更新所有行，但可能覆盖其他事务的更改。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "在执行更新前重新查询对象，确保其存在。",
      "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": "2025-07-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}