{
  "id": "python/flask-sqlalchemy-multiple-results-found",
  "signature": "sqlalchemy.exc.MultipleResultsFound: Multiple rows were found when exactly one was required",
  "signature_zh": "sqlalchemy.exc.MultipleResultsFound: 需要恰好一行时找到多行",
  "regex": "sqlalchemy\\.exc\\.MultipleResultsFound:\\ Multiple\\ rows\\ were\\ found\\ when\\ exactly\\ one\\ was\\ required",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "query.one() or scalar_one() used on a query that returns multiple rows, often due to missing unique constraint or duplicate data.",
  "root_cause_type": "generic",
  "root_cause_zh": "对返回多行的查询使用了 query.one() 或 scalar_one()，通常由于缺少唯一约束或存在重复数据。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Silently returns arbitrary row; hides data bug.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Same silent-truncation risk.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.88,
      "how": "Use .one_or_none() and handle None explicitly",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Add unique constraint: email = db.Column(db.String, unique=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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-08",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}