From de47d27cfbcbf12ec5452a66527677fd3e215247 Mon Sep 17 00:00:00 2001 From: duxingchen Date: Tue, 11 Aug 2026 10:05:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=5Frecalc=5Fproduct=5Flocation?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=20func.or=5F()=20=E2=86=92=20or=5F()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit func 是 SQL 函数调用(如 func.now()),不能替代 WHERE 条件中的 or_ 运算符。 这会导致结束协助分支时 SQL 抛错 500。 --- backend/app/services/task_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/services/task_service.py b/backend/app/services/task_service.py index 5a23a1d..3224e14 100644 --- a/backend/app/services/task_service.py +++ b/backend/app/services/task_service.py @@ -46,7 +46,7 @@ async def _recalc_product_location( 优先级: WIP > PENDING > COMPLETED/ARCHIVED > None """ - from sqlalchemy import select as sa_select, case as sa_case, func as sa_func + from sqlalchemy import select as sa_select, case as sa_case, or_ as sa_or_ product_result = await db.execute( sa_select(Product).where(Product.id == product_id) @@ -60,7 +60,7 @@ async def _recalc_product_location( sa_select(Task) .where( Task.product_id == product_id, - sa_func.or_( + sa_or_( Task.parent_task_id.is_(None), Task.task_type.in_(["TRANSFER", "RECOVERY"]), ),