# sqlalchemy.exc.ArgumentError: SQL expression for WHERE/HAVING role expected, got 5.

- **ID:** `python/sqlalchemy-invalid-expression`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在查询过滤条件中传递了普通 Python 值而不是 SQLAlchemy 表达式。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.4.x | active | — | — |
| 2.0.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   使用列对象构建条件，例如：session.query(User).filter(User.age > 5)
   ```
2. **** (80% success)
   ```
   使用 text() 构造原始 SQL 条件。
   ```

## Dead Ends

- **** — 尝试将值强制转换为字符串，但无法正确生成 SQL。 (60% fail)
- **** — 忽略过滤条件，但查询结果不准确。 (70% fail)
