{
  "id": "python/sqlalchemy-async-session-sync-call",
  "signature": "AttributeError: 'AsyncSession' object has no attribute 'query'",
  "signature_zh": "AttributeError: 'AsyncSession' 对象没有属性 'query'",
  "regex": "AttributeError:\\ 'AsyncSession'\\ object\\ has\\ no\\ attribute\\ 'query'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Using synchronous session methods like session.query() on an AsyncSession; async sessions require awaitable methods.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 AsyncSession 上使用同步会话方法如 session.query()；异步会话需要使用可等待的方法。",
  "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": "AsyncSession doesn't have a query method; you must use select().",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "query() is not a coroutine; it doesn't exist.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Use SQLAlchemy 2.0 style: result = await session.execute(select(User).where(User.id == 1))",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.5,
      "how": "For legacy, use AsyncSession with sync_session_factory but that's not recommended.",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}