# one() 找到了多行结果

- **ID:** `python/sqlalchemy-orm-exc-multiple-results-found`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用 .one() 方法但查询返回了多行，该方法期望恰好一个结果。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Use one_or_none() method** (90% 成功率)
   ```
   Use .one_or_none() to handle zero or one result, then check for None.
   ```
2. **Add unique constraints to query** (95% 成功率)
   ```
   Refine the query with additional filters to ensure uniqueness, e.g., filter by primary key.
   ```

## 无效尝试

- **Using .first() without addressing duplicates** —  (70% 失败率)
- **Adding LIMIT 1 to query** —  (50% 失败率)
