# sqlalchemy.exc.ArgumentError: Invalid sort expression: 'invalid_column'

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

## Root Cause

Passing a string that does not correspond to a valid column or expression to the order_by method.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Use the column attribute directly** (98% success)
   ```
   session.query(User).order_by(User.name).all()
   ```
2. **Use text() for raw SQL expressions** (90% success)
   ```
   from sqlalchemy import text
session.query(User).order_by(text('name DESC')).all()
   ```

## Dead Ends

- **Using the string as is without validation** — The error will persist. (100% fail)
- **Renaming the column to match the string** — This changes the database schema unnecessarily. (50% fail)
