mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-25 09:32:33 +00:00
选对象按名字查改用 ilike(复核 L3):PostgreSQL 上 LIKE 分 ASCII 大小写、SQLite 不分,两种库说法不一;% 和 _ 照 runs._like 转义、按字面匹配。补测试
This commit is contained in:
@@ -618,7 +618,10 @@ async def trigger_options(event: str | None = None, q: str | None = None, select
|
||||
async def page(model: Any, *conds: Any) -> tuple[list[Any], bool]:
|
||||
query = select(model).where(*conds)
|
||||
if words:
|
||||
query = query.where(model.name.contains(words, autoescape=True))
|
||||
# 名字里含这几个字,不分大小写:PostgreSQL 上 LIKE 分 ASCII 大小写、SQLite 不分,一律 ilike(转义同 runs._like)
|
||||
from app.api.runs import _like
|
||||
|
||||
query = query.where(model.name.ilike(f"%{_like(words)}%", escape="\\"))
|
||||
rows = list((await session.execute(query.order_by(model.name, model.id).limit(limit + 1))).scalars())
|
||||
more = len(rows) > limit
|
||||
rows = rows[:limit]
|
||||
|
||||
Reference in New Issue
Block a user