From 3d4e5bb4cbd3123f1f5e39f5c0422c748afad549 Mon Sep 17 00:00:00 2001 From: ymq Date: Wed, 16 Sep 2026 13:38:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(db=5Fquery):=20where=E5=AD=97=E9=9D=A2?= =?UTF-8?q?=E9=87=8F%=E8=BD=AC=E4=B9=89=E2=80=94=E2=80=94LIKE=20'%?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E8=AF=8D%'=E7=9A=84%=E8=A2=ABaiomysql?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=9B=BF=E6=8D=A2=E5=BD=93=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E7=AC=A6=E8=87=B4TypeError=20not=20enough=20?= =?UTF-8?q?arguments(2026-09-16=E7=94=98=E8=82=83=E9=A1=B9=E7=9B=AEagent?= =?UTF-8?q?=E5=AE=9E=E6=B5=8B:=E6=9F=A5=E8=8A=82=E8=83=BD=E8=B5=84?= =?UTF-8?q?=E8=B4=A8=E7=9B=B4=E6=8E=A5=E5=B4=A9);=E9=A1=BA=E5=B8=A6?= =?UTF-8?q?=E7=99=BD=E5=90=8D=E5=8D=95=E8=A1=A5bid=5Fmaterial=5Fgaps?= =?UTF-8?q?=E8=A1=A8(=E6=9D=90=E6=96=99=E7=BC=BA=E5=8F=A3=E6=B8=85?= =?UTF-8?q?=E5=8D=95=E5=8F=AF=E6=9F=A5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/db_query.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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()