From d555c70af9386b5364be9b9e225edc9453c547c5 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Thu, 12 Feb 2026 18:18:29 +0700 Subject: [PATCH] fix: script insert --- src/controllers/OrganizationController.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 9f1e1615..d1b47518 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -7983,8 +7983,15 @@ export class OrganizationController extends Controller { // OrgRoot (sync first - no parent dependencies) // If we manually created orgRootCurrent, skip syncOrgLevel and set up mapping directly // to avoid double insert (syncOrgLevel would try to insert again because IDs don't match) - let orgRootResult: { mapping: OrgIdMapping; counts: { deleted: number; updated: number; inserted: number } }; - if (orgRootCurrent && orgRootDraft && orgRootCurrent.ancestorDNA === orgRootDraft.ancestorDNA) { + let orgRootResult: { + mapping: OrgIdMapping; + counts: { deleted: number; updated: number; inserted: number }; + }; + if ( + orgRootCurrent && + orgRootDraft && + orgRootCurrent.ancestorDNA === orgRootDraft.ancestorDNA + ) { // Manually created - set up mapping directly const rootMapping: OrgIdMapping = { byAncestorDNA: new Map([[orgRootDraft.ancestorDNA, orgRootCurrent.id]]), @@ -8479,7 +8486,7 @@ export class OrganizationController extends Controller { for (const draft of toInsert) { const newNode: any = queryRunner.manager.create(entityClass, { ...draft, - id: draft.id, + id: undefined, orgRevisionId: currentRevisionId, });