fix: sqlor占位符语法错——角色IN子句用字面量非参数占位致永远匹配不到角色
部署实测抓到: 工单TK0002状态human_pending且assignee_role=owner.maintainer,
但provider用owner.maintainer角色查待办返回0条。
根因: 动态IN子句拼接时 ph 生成的是字面量 'r0' 而非 sqlor 的参数占位格式,
渲染出的SQL是 assignee_role IN ('r0') 恒不匹配任何真实角色值,
params里设置的 r0=owner.maintainer 从未被SQL引用。
两处同款错:
- todos.py 角色池待办条件(human_pending且assignee_role在我的角色)
- core.py list_staff_tickets 的 pending 队列条件
修法: 占位符改为 sqlor 的标准参数格式(dollar-brace-key-brace-dollar)。
渲染SQL现为 assignee_role IN (参数占位) 正确绑定。
教训: sqlor 动态 IN 子句拼接, 占位符必须用标准参数格式,
裸引号包键名会变成SQL字面量常量, 静默匹配0行不报错——极难排查。
This commit is contained in:
parent
d151ea76d5
commit
8e0bbdbbd1
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user