From 89212784473878027eb2a06b193f7c4fafecbb9b Mon Sep 17 00:00:00 2001 From: Michael Manganiello Date: Sat, 6 Jan 2024 12:56:08 -0500 Subject: [PATCH] fix(server): Execute query in AlbumRepository.removeAsset method (#6216) The current `removeAsset` implementation just builds the query but does not execute it. That also seems to be the reason the `@GenerateSql` decorator was commented out. --- server/src/infra/repositories/album.repository.ts | 5 +++-- server/src/infra/sql/album.repository.sql | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/src/infra/repositories/album.repository.ts b/server/src/infra/repositories/album.repository.ts index a7698b952c..ed92bbfe15 100644 --- a/server/src/infra/repositories/album.repository.ts +++ b/server/src/infra/repositories/album.repository.ts @@ -177,14 +177,15 @@ export class AlbumRepository implements IAlbumRepository { }); } - // @GenerateSql({ params: [DummyValue.UUID] }) + @GenerateSql({ params: [DummyValue.UUID] }) async removeAsset(assetId: string): Promise { // Using dataSource, because there is no direct access to albums_assets_assets. await this.dataSource .createQueryBuilder() .delete() .from('albums_assets_assets') - .where('"albums_assets_assets"."assetsId" = :assetId', { assetId }); + .where('"albums_assets_assets"."assetsId" = :assetId', { assetId }) + .execute(); } @GenerateSql({ params: [{ albumId: DummyValue.UUID, assetIds: [DummyValue.UUID] }] }) diff --git a/server/src/infra/sql/album.repository.sql b/server/src/infra/sql/album.repository.sql index 4b2bfe19ac..8b6d170841 100644 --- a/server/src/infra/sql/album.repository.sql +++ b/server/src/infra/sql/album.repository.sql @@ -508,6 +508,11 @@ FROM WHERE "AlbumEntity"."deletedAt" IS NULL +-- AlbumRepository.removeAsset +DELETE FROM "albums_assets_assets" +WHERE + "albums_assets_assets"."assetsId" = $1 + -- AlbumRepository.removeAssets DELETE FROM "albums_assets_assets" WHERE