修复撤回500: 先删task_logs+task_records再删task,加delete import
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
from __future__ import annotations
|
||||
import uuid
|
||||
from fastapi import HTTPException, status
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import select, delete
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
@ -337,6 +337,11 @@ async def recall_task(
|
||||
product.current_location_id = parent.assignee_id
|
||||
product.overall_status = parent.task_name
|
||||
|
||||
# 先删除关联的 task_logs 和 task_records
|
||||
await db.execute(delete(TaskLog).where(TaskLog.task_id == task_id))
|
||||
await db.execute(delete(TaskRecord).where(TaskRecord.task_id == task_id))
|
||||
await db.flush()
|
||||
|
||||
# 删除 PENDING 子任务
|
||||
await db.delete(task)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user