hotfix: func→sa_func 解决局部变量遮蔽

This commit is contained in:
2026-08-12 15:52:06 +08:00
parent b21df33e0a
commit 6016f92dd0

View File

@ -2,7 +2,7 @@
from __future__ import annotations from __future__ import annotations
import uuid import uuid
from fastapi import HTTPException, status from fastapi import HTTPException, status
from sqlalchemy import select, or_, cast, String, delete, update, func from sqlalchemy import select, or_, cast, String, delete, update
from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import selectinload from sqlalchemy.orm import selectinload
@ -473,7 +473,7 @@ async def get_all_products(
).subquery() ).subquery()
ranked = ( ranked = (
select(TR.task_id, TR.remark, TR.created_at, Task.product_id, select(TR.task_id, TR.remark, TR.created_at, Task.product_id,
func.row_number().over( sa_func.row_number().over(
partition_by=Task.product_id, partition_by=Task.product_id,
order_by=TR.created_at.desc() order_by=TR.created_at.desc()
).label("rn")) ).label("rn"))