mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-22 08:22:04 +00:00
两种库行为再对齐一轮(复核 NUL、R-a4、R-a6、R-a7、R-a10)
- 编排者的决定:PostgreSQL 下文本列写入时去掉 NUL 字符(before_cursor_execute 钩子,只装在应用库引擎上,看所有字符串参数,没有 NUL 的原样交回),SQLite 不变;同 JSON 列的处理 - R-a4 应用库地址里的 sslmode= 换成 asyncpg 的 ssl=(取值同一套),sslrootcert 等证书参数、application_name 这类 asyncpg 不收的参数启动时就报错并说怎么写(证书用 PGSSLROOTCERT 等环境变量);断点库连接串换回 sslmode= - R-a6 不分大小写的搜索换成 db/portable.contains_ci:SQLite 上同 ilike(lower LIKE lower),PostgreSQL 上模式带 COLLATE "default"(列是 COLLATE "C",列上的 ILIKE 只认 ASCII,É/é、Ж/ж、全角A/a 匹配不上);运行列表按名字、对象索引按注释两处都改;改正 db/postgres 里那句说明 - R-a7 JSON 守卫改成编译层:tests/jsonguard 挂在应用库编译器上(conftest,两种库、跑全量时一直生效),整个 JSON 值出现在 = / != / IN / IS DISTINCT FROM / 大小比较、SELECT DISTINCT、GROUP BY、ORDER BY、UNION(去重的几种)里就报错;按类型认,变量别名、跨行 order_by、select(Run.origin).distinct()、JSON 下标的比较都抓得到,测试拿这些反例证明,json_eq、IS NULL、UNION ALL 不受影响。原来的逐行正则测试删掉 - R-a10 json_eq 两种库同一语义、按 JSON 类型比:字符串只等于字符串,数只等于数(1 等于 1.0),True / False 只等于 JSON 的 true / false(SQLite 上用 json_type 分开,以前 1 能匹配 true);非标量 TypeError。json_text 两种库都是「字符串取本身、别的取 JSON 写法」(SQLite 上同 PostgreSQL 的 ->>),数 1 的 json_text 两边都是 '1' - db/postgres 说明里写清 NULL 排序补写的范围(只认直接按列排的)
This commit is contained in:
@@ -213,7 +213,7 @@ async def list_runs(
|
||||
"""
|
||||
stmt = _filtered(select(Run), workflow_id=workflow_id, status=status, run_class=run_class, q=q,
|
||||
schedule_id=schedule_id, origin_kind=origin_kind)
|
||||
stmt = stmt.order_by(Run.created_at.desc()).limit(limit)
|
||||
stmt = stmt.order_by(Run.created_at.desc(), Run.id.desc()).limit(limit)
|
||||
if before is not None:
|
||||
stmt = stmt.where(Run.created_at < before)
|
||||
return list((await session.execute(stmt)).scalars())
|
||||
@@ -265,7 +265,10 @@ def _filtered(stmt: Any, *, workflow_id: str | None, status: str | None, run_cla
|
||||
if classes := _csv(run_class):
|
||||
stmt = stmt.where(Run.run_class.in_(classes))
|
||||
if q and q.strip():
|
||||
stmt = stmt.where(Run.workflow_name.ilike(f"%{_like(q.strip())}%", escape="\\"))
|
||||
# 不分大小写(db/portable.contains_ci):PostgreSQL 的文本列按字节排序(COLLATE "C"),列上的 ILIKE 只认 ASCII 的大小写
|
||||
from app.db.portable import contains_ci
|
||||
|
||||
stmt = stmt.where(contains_ci(Run.workflow_name, q.strip()))
|
||||
if schedule_id:
|
||||
stmt = stmt.where(Run.schedule_id == schedule_id)
|
||||
if origins := _csv(origin_kind):
|
||||
@@ -281,11 +284,6 @@ def _csv(value: str | None) -> list[str]:
|
||||
return [v.strip() for v in (value or "").split(",") if v.strip()]
|
||||
|
||||
|
||||
def _like(text: str) -> str:
|
||||
"""用户输入里的 % 和 _ 按字面匹配,不当通配符。"""
|
||||
return text.replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_")
|
||||
|
||||
|
||||
@router.get("/{run_id}", response_model=RunOut)
|
||||
async def get_run(run_id: str, session: AsyncSession = Depends(get_session)) -> RunOut:
|
||||
run = await session.get(Run, run_id)
|
||||
@@ -343,7 +341,7 @@ async def list_artifacts(
|
||||
) -> list[dict[str, Any]]:
|
||||
"""这次运行产出的全部工件引用。审阅出具物时从这里下钻到完整证据。"""
|
||||
rows = await session.execute(
|
||||
select(Artifact).where(Artifact.run_id == run_id).order_by(Artifact.created_at)
|
||||
select(Artifact).where(Artifact.run_id == run_id).order_by(Artifact.created_at, Artifact.id)
|
||||
)
|
||||
return [
|
||||
{
|
||||
@@ -753,7 +751,7 @@ async def list_approvals(
|
||||
.join(Task, Task.approval_id == Approval.id, isouter=True)
|
||||
# 别人的个人应用刷新、个人蓝图试运行上的审批不列(只给拥有者,同运行列表)
|
||||
.where(or_(Run.id.is_(None), not_(hidden_runs(current_principal()))))
|
||||
.order_by(Approval.created_at.desc())
|
||||
.order_by(Approval.created_at.desc(), Approval.id.desc())
|
||||
.limit(limit)
|
||||
)
|
||||
if status != "all" and (statuses := _csv(status)):
|
||||
|
||||
Reference in New Issue
Block a user