diff --git a/server/src/repositories/person.repository.ts b/server/src/repositories/person.repository.ts index 64ae548c1bfa8..3ba9e238872b9 100644 --- a/server/src/repositories/person.repository.ts +++ b/server/src/repositories/person.repository.ts @@ -279,7 +279,7 @@ export class PersonRepository implements IPersonRepository { faceIdsToRemove: string[], embeddingsToAdd?: FaceSearchEntity[], ): Promise { - const query = this.faceSearchRepository.createQueryBuilder().select('1'); + const query = this.faceSearchRepository.createQueryBuilder().select('1').fromDummy(); if (facesToAdd.length > 0) { const insertCte = this.assetFaceRepository.createQueryBuilder().insert().values(facesToAdd); query.addCommonTableExpression(insertCte, 'added'); @@ -296,6 +296,7 @@ export class PersonRepository implements IPersonRepository { if (embeddingsToAdd?.length) { const embeddingCte = this.faceSearchRepository.createQueryBuilder().insert().values(embeddingsToAdd).orIgnore(); query.addCommonTableExpression(embeddingCte, 'embeddings'); + query.getQuery(); // typeorm mixes up parameters without this } await query.execute(); diff --git a/server/src/services/person.service.ts b/server/src/services/person.service.ts index 77694d8e5db58..624fb46b6d68b 100644 --- a/server/src/services/person.service.ts +++ b/server/src/services/person.service.ts @@ -325,7 +325,7 @@ export class PersonService extends BaseService { if (match && !mlFaceIds.delete(match.id)) { embeddings.push({ faceId: match.id, embedding }); - } else { + } else if (!match) { const faceId = this.cryptoRepository.randomUUID(); facesToAdd.push({ id: faceId,