fix(gateway): resolve_project 改两步查询避免 JOIN 触发 collation 冲突
This commit is contained in:
parent
286f0cb4dd
commit
bb29d6d634
@ -83,15 +83,18 @@ class Gateway:
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext("pipeline") as sor:
|
async with db.sqlorContext("pipeline") as sor:
|
||||||
recs = await sor.sqlExe(
|
recs = await sor.sqlExe(
|
||||||
"SELECT s.current_project_id, s.default_llm_id, l.name as llm_name "
|
"SELECT current_project_id, default_llm_id FROM pipeline_agent_settings WHERE user_id=${u}$",
|
||||||
"FROM pipeline_agent_settings s "
|
|
||||||
"LEFT JOIN llm l ON l.id = s.default_llm_id AND l.status='active' "
|
|
||||||
"WHERE s.user_id=${u}$",
|
|
||||||
{"u": user_id})
|
{"u": user_id})
|
||||||
if recs:
|
if recs:
|
||||||
ctx["pid"] = getattr(recs[0], "current_project_id", "") or ""
|
ctx["pid"] = getattr(recs[0], "current_project_id", "") or ""
|
||||||
ctx["default_llm_id"] = getattr(recs[0], "default_llm_id", "") or ""
|
ctx["default_llm_id"] = getattr(recs[0], "default_llm_id", "") or ""
|
||||||
ctx["default_llm_name"] = getattr(recs[0], "llm_name", "") or ""
|
# 单独查 llm.name(避免 JOIN 触发两表字段 collation 不一致)
|
||||||
|
if ctx["default_llm_id"]:
|
||||||
|
llm_recs = await sor.sqlExe(
|
||||||
|
"SELECT name FROM llm WHERE id=${id}$ AND status='active'",
|
||||||
|
{"id": ctx["default_llm_id"]})
|
||||||
|
if llm_recs:
|
||||||
|
ctx["default_llm_name"] = getattr(llm_recs[0], "name", "") or ""
|
||||||
if ctx["pid"]:
|
if ctx["pid"]:
|
||||||
proj = await sor.sqlExe(
|
proj = await sor.sqlExe(
|
||||||
"SELECT name, pipeline_id FROM sd_projects WHERE id=${p}$",
|
"SELECT name, pipeline_id FROM sd_projects WHERE id=${p}$",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user