From 0d44a98377da008482a86374dee16ceb5f13885e Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Fri, 11 Dec 2020 14:46:40 +0100 Subject: [PATCH] bug in updateWorkshop --- src/datasources/db/workshopAPI.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/datasources/db/workshopAPI.ts b/src/datasources/db/workshopAPI.ts index b171010..de04f89 100644 --- a/src/datasources/db/workshopAPI.ts +++ b/src/datasources/db/workshopAPI.ts @@ -55,6 +55,8 @@ export class WorkshopAPI extends DataSource { async updateWorkshop (workshop: any, userId: number) { const keepLock = workshop.keepLock; delete workshop.keepLock; + const workshopTypeId = workshop.workshopTypeId; + delete workshop.workshopTypeId; await this.connection.transaction(async (entityManger: EntityManager) => { if (await LockUtils.isLocked(entityManger, Workshop, 'w', workshop.id, userId)) { throw new ResourceLockedError('Workshop', 'Attempting to update locked resource'); @@ -71,6 +73,11 @@ export class WorkshopAPI extends DataSource { throw new NotFoundError('Workshop', 'id', workshop.id); } }); + workshopTypeId && await entityManger.getRepository(Workshop) + .createQueryBuilder('w') + .relation(Workshop, 'workshopTypeId') + .of(workshop.id) + .set(workshopTypeId); }); !keepLock && await this.unlockWorkshop(workshop.id, userId); return await this.workshopById(workshop.id);