Skip to content

Commit 87d60d5

Browse files
committed
fix: stop starting a nested transaction when a transaction is provided
1 parent a16c387 commit 87d60d5

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

  • services/libs/data-access-layer/src/old/apps/members_enrichment_worker

services/libs/data-access-layer/src/old/apps/members_enrichment_worker/index.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -469,25 +469,28 @@ export async function deleteMemberOrg(db: DbConnOrTx, memberId: string, organiza
469469
})
470470
}
471471

472-
export async function deleteMemberOrgById(db: DbConnOrTx, memberId: string, id: string) {
473-
await db.tx(async (tx) => {
474-
await tx.none(
475-
`
472+
export async function deleteMemberOrgById(
473+
tx: DbTransaction,
474+
memberId: string,
475+
id: string,
476+
): Promise<void> {
477+
// Execute directly on the provided transaction to avoid creating nested savepoints
478+
await tx.none(
479+
`
476480
DELETE FROM "memberOrganizationAffiliationOverrides"
477481
WHERE "memberOrganizationId" = $(id);
478-
`,
479-
{ id },
480-
)
482+
`,
483+
{ id },
484+
)
481485

482-
await tx.none(
483-
`
486+
await tx.none(
487+
`
484488
UPDATE "memberOrganizations"
485489
SET "deletedAt" = NOW()
486490
WHERE "memberId" = $(memberId) and id = $(id);
487-
`,
488-
{ memberId, id },
489-
)
490-
})
491+
`,
492+
{ memberId, id },
493+
)
491494
}
492495

493496
export async function findMemberOrgs(db: DbStore, memberId: string, orgId: string) {

0 commit comments

Comments
 (0)