fix(db_query): where字面量%转义——LIKE '%关键词%'的%被aiomysql参数替换当格式占位符致TypeError not enough arguments(2026-09-16甘肃项目agent实测:查节能资质直接崩);顺带白名单补bid_material_gaps表(材料缺口清单可查)
This commit is contained in:
parent
38efb3eb17
commit
3d4e5bb4cb
@ -53,6 +53,7 @@ PIPELINE_TABLE_SCOPES = {
|
||||
'bid_reviews': "SELECT * FROM bid_reviews WHERE project_id=${pid}$",
|
||||
'bid_analysis_history': "SELECT * FROM bid_analysis_history WHERE project_id=${pid}$",
|
||||
'bid_cost_benefit': "SELECT * FROM bid_cost_benefit WHERE project_id=${pid}$",
|
||||
'bid_material_gaps': "SELECT * FROM bid_material_gaps WHERE project_id=${pid}$",
|
||||
}
|
||||
|
||||
ALL_SCOPES = dict(TABLE_SCOPES, **PIPELINE_TABLE_SCOPES)
|
||||
@ -108,7 +109,10 @@ async def tool_query_project_data(sor, table: str, project_id: str,
|
||||
if not re.match(safe_cond, w, re.I):
|
||||
return ('FAIL: where 附加过滤只允许「列名 运算符 字面量」的 AND 组合'
|
||||
"(禁子查询/UNION/分号/注释)。示例: state='running'")
|
||||
extra = ' AND (' + w + ')'
|
||||
# 2026-09-16 甘肃项目实测 bug:LIKE '%节能%' 的 % 会被 aiomysql 的
|
||||
# query % args 参数替换当成格式占位符 → TypeError: not enough arguments。
|
||||
# 字面量里的 % 必须转义为 %%(替换后还原为字面 %)。
|
||||
extra = ' AND (' + w.replace('%', '%%') + ')'
|
||||
order = ''
|
||||
if order_by and str(order_by).strip():
|
||||
o = str(order_by).strip()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user