From 86adf1aa8c61eac475ee5678060e9c417b10c5c9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 10 Sep 2026 17:09:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20sqlor=E5=8D=A0=E4=BD=8D=E7=AC=A6?= =?UTF-8?q?=E5=A4=96=E5=B1=82=E5=BC=95=E5=8F=B7=E8=87=B4=E5=8F=8C=E9=87=8D?= =?UTF-8?q?=E5=BC=95=E5=8F=B71064=E2=80=94=E2=80=94=E5=8E=BB=E6=8E=89ph?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E7=AC=A6=E7=9A=84=E5=8D=95=E5=BC=95=E5=8F=B7?= =?UTF-8?q?=E5=8C=85=E8=A3=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一提交修占位符时引入的新错: 给 dollar-brace 占位符加了外层单引号, 渲染成 IN ('占位符') → sqlor参数化时aiomysql再自动加引号 → 双重引号 IN (''owner.maintainer'') → MySQL把空串后 owner.maintainer 当裸标识符 → 1064。 证据: 同文件其余占位符(user/ticket等)均无外层引号且全部成功, 仅动态IN子句两处(todos角色池+core待认领队列)加了引号即报错。 修法: 去掉外层单引号, 占位符直接拼入IN子句, 与同文件其余用法一致。 渲染SQL现为 assignee_role IN (占位符) 正确绑定参数。 教训: sqlor占位符(dollar-brace-key-brace-dollar)由驱动参数化并自动加引号, 手工再包单引号=双重引号必炸; 拼接动态IN子句时占位符裸写不加引号。 --- ticket/core.py | 2 +- ticket/todos.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ticket/core.py b/ticket/core.py index 32be136..8f1e529 100644 --- a/ticket/core.py +++ b/ticket/core.py @@ -545,7 +545,7 @@ async def list_staff_tickets(user_id, roles=None, queue='all', limit=100): if queue == 'pending': if not roles: return [] - ph = ','.join("'${role%d}$'" % i for i in range(len(roles))) + ph = ','.join("${role%d}$" % i for i in range(len(roles))) for i, r in enumerate(roles): params['role%d' % i] = r cond = ("status='human_pending' AND assignee_role IN (%s)" % ph) diff --git a/ticket/todos.py b/ticket/todos.py index 54c81df..b20d011 100644 --- a/ticket/todos.py +++ b/ticket/todos.py @@ -40,7 +40,7 @@ async def list_ticket_todos(user_id, roles=None, limit=100): conds.append("(assignee_id=${u}$ AND status='human_processing')") # ③ 角色池视角:待认领且受理角色∈我的角色 if roles: - ph = ','.join("'${r%d}$'" % i for i in range(len(roles))) + ph = ','.join("${r%d}$" % i for i in range(len(roles))) for i, r in enumerate(roles): params['r%d' % i] = r conds.append("(status='human_pending' AND assignee_role IN (%s))" % ph)