Skip to content

Commit

Permalink
fix(ai): 修复模型版本编辑时名称重复校验问题 (#1123)
Browse files Browse the repository at this point in the history
**问题**
重命名校验时使用`em.findOne()`没有过滤不是同一模型下的其他相同版本名称的数据

![image](https://github.com/PKUHPC/SCOW/assets/43978285/5e293e58-5ebd-42f3-8f43-e3658c5b8948)

**解决后**
不同模型下相同版本名称的数据都可以正常编辑

![image](https://github.com/PKUHPC/SCOW/assets/43978285/3571915b-ac22-46e0-9643-0ac4e685ddf0)

![image](https://github.com/PKUHPC/SCOW/assets/43978285/db1594af-67d6-4c5c-9d24-ad692d18694a)
  • Loading branch information
piccaSun authored Feb 6, 2024
1 parent 941340a commit 8cba2eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-ladybugs-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@scow/ai": patch
---

修复修改模型版本时校验名称重复错误问题
4 changes: 2 additions & 2 deletions apps/ai/src/server/trpc/route/model/modelVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export const updateModelVersion = procedure
if (!modelVersion)
throw new TRPCError({ code: "NOT_FOUND", message: `ModelVersion ${versionId} not found` });

const modelVersionExist = await em.findOne(ModelVersion, { versionName });
if (modelVersionExist && modelVersionExist !== modelVersion) {
const modelVersionNameExist = await em.findOne(ModelVersion, { versionName, model, id: { $ne: versionId } });
if (modelVersionNameExist) {
throw new TRPCError({ code: "CONFLICT", message: "ModelVersion alreay exist" });
}

Expand Down

0 comments on commit 8cba2eb

Please sign in to comment.