From 5d40cdcd169e0389b52e3bc8e63c898aceabf2d5 Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 18 Aug 2026 15:50:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B9=E7=9B=AE=E5=A4=87=E4=BB=BD/?= =?UTF-8?q?=E5=88=A0=E9=99=A4=20SQL=20=E8=B7=A8=E8=A1=A8=20collation=20?= =?UTF-8?q?=E4=B8=8D=E5=8C=B9=E9=85=8D=E2=80=94=E2=80=94general=5Fci=20?= =?UTF-8?q?=E8=A1=A8=E6=AF=94=E8=BE=83=E5=88=97=E7=BB=9F=E4=B8=80=20COLLAT?= =?UTF-8?q?E=20utf8mb4=5Funicode=5Fci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipeline_service/project_capability.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pipeline_service/project_capability.py b/pipeline_service/project_capability.py index db8ae1f..aa7293a 100644 --- a/pipeline_service/project_capability.py +++ b/pipeline_service/project_capability.py @@ -193,12 +193,12 @@ async def _dump_project_records(sor, project_id): 'sd_projects': "SELECT * FROM sd_projects WHERE id=${pid}$", 'sd_iterations': "SELECT * FROM sd_iterations WHERE project_id=${pid}$", 'pipeline_tasks': "SELECT * FROM pipeline_tasks WHERE tenant_id=${pid}$", - 'pipeline_deliverables': "SELECT * FROM pipeline_deliverables WHERE project_id=${pid}$", - 'pipeline_project_agents': "SELECT * FROM pipeline_project_agents WHERE project_id=${pid}$", + 'pipeline_deliverables': "SELECT * FROM pipeline_deliverables WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", + 'pipeline_project_agents': "SELECT * FROM pipeline_project_agents WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", 'pipeline_agent_questions': "SELECT * FROM pipeline_agent_questions WHERE tenant_id=${pid}$", 'sd_deploy_envs': "SELECT * FROM sd_deploy_envs WHERE project_id=${pid}$", 'sd_features': "SELECT * FROM sd_features WHERE project_id=${pid}$", - 'sd_project_repos': "SELECT * FROM sd_project_repos WHERE project_id=${pid}$", + 'sd_project_repos': "SELECT * FROM sd_project_repos WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", } for tbl, sql in direct.items(): try: @@ -212,9 +212,9 @@ async def _dump_project_records(sor, project_id): 'sd_bugs': "SELECT * FROM sd_bugs WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", 'sd_test_plans': "SELECT * FROM sd_test_plans WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", 'sd_test_cases': "SELECT * FROM sd_test_cases WHERE plan_id IN (SELECT id FROM sd_test_plans WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$))", - 'sd_conversations': "SELECT * FROM sd_conversations WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", - 'pipeline_conversations': "SELECT * FROM pipeline_conversations WHERE iteration_id=${pid}$ OR iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", - 'audit_log': "SELECT * FROM audit_log WHERE tenant_id=${pid}$ ORDER BY created_at ASC", + 'sd_conversations': "SELECT * FROM sd_conversations WHERE iteration_id COLLATE utf8mb4_unicode_ci IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", + 'pipeline_conversations': "SELECT * FROM pipeline_conversations WHERE iteration_id COLLATE utf8mb4_unicode_ci=${pid}$ OR iteration_id COLLATE utf8mb4_unicode_ci IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", + 'audit_log': "SELECT * FROM audit_log WHERE tenant_id COLLATE utf8mb4_unicode_ci=${pid}$ ORDER BY created_at ASC", } for tbl, sql in indirect.items(): try: @@ -315,22 +315,22 @@ async def delete_project(project_id, who=None, agent_id=None, confirm=False): "DELETE FROM sd_test_cases WHERE plan_id IN (SELECT id FROM sd_test_plans WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$))", "DELETE FROM sd_bugs WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", "DELETE FROM sd_test_plans WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", - "DELETE FROM sd_conversations WHERE iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", - "DELETE FROM pipeline_conversations WHERE iteration_id=${pid}$ OR iteration_id IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", + "DELETE FROM sd_conversations WHERE iteration_id COLLATE utf8mb4_unicode_ci IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", + "DELETE FROM pipeline_conversations WHERE iteration_id COLLATE utf8mb4_unicode_ci=${pid}$ OR iteration_id COLLATE utf8mb4_unicode_ci IN (SELECT id FROM sd_iterations WHERE project_id=${pid}$)", ] for sql in indirect: await sor.sqlExe(sql, {"pid": project_id}) # 3. 删除直接关联表(project_id / tenant_id) direct = [ - "DELETE FROM pipeline_deliverables WHERE project_id=${pid}$", - "DELETE FROM pipeline_project_agents WHERE project_id=${pid}$", + "DELETE FROM pipeline_deliverables WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", + "DELETE FROM pipeline_project_agents WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", "DELETE FROM pipeline_agent_questions WHERE tenant_id=${pid}$", "DELETE FROM sd_deploy_envs WHERE project_id=${pid}$", "DELETE FROM sd_features WHERE project_id=${pid}$", - "DELETE FROM sd_project_repos WHERE project_id=${pid}$", + "DELETE FROM sd_project_repos WHERE project_id COLLATE utf8mb4_unicode_ci=${pid}$", "DELETE FROM pipeline_tasks WHERE tenant_id=${pid}$", - "DELETE FROM audit_log WHERE tenant_id=${pid}$", + "DELETE FROM audit_log WHERE tenant_id COLLATE utf8mb4_unicode_ci=${pid}$", "DELETE FROM sd_iterations WHERE project_id=${pid}$", "DELETE FROM sd_projects WHERE id=${pid}$", ]