diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index eb1f6c3..e2be6b1 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -127,10 +127,11 @@ def get_information_list( if user_id: query = query.filter(Information.user_id == user_id) - # 成交日期过滤 - 使用cast确保字符串与date字段正确比较 + # 成交日期过滤 if deal_date: - from sqlalchemy import cast, String - query = query.filter(cast(Information.deal_date, String) == deal_date) + from datetime import date + deal_date_obj = date.fromisoformat(deal_date) + query = query.filter(Information.deal_date == deal_date_obj) # 按创建时间倒序 query = query.order_by(Information.created_at.desc())