fix: _find_project fuzzy match in Python (avoid aiomysql % format issue)
This commit is contained in:
parent
168b5aaa88
commit
588e5be5d6
@ -447,12 +447,16 @@ async def _find_project(sor, name, org_id):
|
|||||||
{"name": name, "oid": org_id})
|
{"name": name, "oid": org_id})
|
||||||
if recs:
|
if recs:
|
||||||
return recs[0]
|
return recs[0]
|
||||||
# Fuzzy match: name contains keyword
|
# Fuzzy: load all projects for this org and match in Python
|
||||||
# Use f-string for LIKE to avoid aiomysql % escaping issues
|
all_recs = await sor.sqlExe(
|
||||||
kw = name.replace("'", "''")
|
"SELECT id, name FROM sd_projects WHERE org_id=${oid}$",
|
||||||
sql = f"SELECT id, name FROM sd_projects WHERE name LIKE '%{kw}%' AND org_id='{org_id}' LIMIT 1"
|
{"oid": org_id})
|
||||||
recs = await sor.sqlExe(sql, {})
|
kw = name.lower()
|
||||||
return recs[0] if recs else None
|
for rec in (all_recs or []):
|
||||||
|
rname = (getattr(rec, 'name', '') or '').lower()
|
||||||
|
if kw in rname:
|
||||||
|
return rec
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
# ==================== 问题路由 ====================
|
# ==================== 问题路由 ====================
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user