diff --git a/pipeline_service/db_query.py b/pipeline_service/db_query.py index fb8c747..8901c0b 100644 --- a/pipeline_service/db_query.py +++ b/pipeline_service/db_query.py @@ -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()