{
  "id": "python/sqlalchemy-invalid-boolean-filter",
  "signature": "sqlalchemy.exc.ProgrammingError: (psycopg2.errors.SyntaxError) syntax error at or near \"and\"",
  "signature_zh": "语法错误：在 \"and\" 附近有语法错误",
  "regex": "sqlalchemy\\.exc\\.ProgrammingError:\\ \\(psycopg2\\.errors\\.SyntaxError\\)\\ syntax\\ error\\ at\\ or\\ near\\ \"and\"",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Incorrectly combining filter conditions using Python 'and' instead of SQLAlchemy's and_() function.",
  "root_cause_type": "generic",
  "root_cause_zh": "错误地使用 Python 'and' 而不是 SQLAlchemy 的 and_() 函数组合过滤条件。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "May work for some cases but can cause operator precedence issues.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "SQLAlchemy may interpret incorrectly.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "from sqlalchemy import and_\nresult = session.query(User).filter(and_(User.age > 18, User.active == True)).all()",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "result = session.query(User).filter(User.age > 18).filter(User.active == True).all()",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}