From 9faa2d8069d8ac50b3fba40e26bfb2e736f116d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Sat, 11 Apr 2026 22:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E6=9C=9F=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E4=BD=BF=E7=94=A8=E6=AD=A3=E7=A1=AE=E7=9A=84date?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/information.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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())