From dff7613b316e1abfc8dcb92e52e46d5662d146b3 Mon Sep 17 00:00:00 2001 From: Thiago Ramalho Date: Mon, 22 Apr 2024 14:53:47 -0300 Subject: [PATCH] fix(typeorm-common): update repository to get entityManager from options when needed --- .../src/proxies/entity-manager.proxy.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/typeorm-common/src/proxies/entity-manager.proxy.ts b/packages/typeorm-common/src/proxies/entity-manager.proxy.ts index 187f85ad3..348dbe643 100644 --- a/packages/typeorm-common/src/proxies/entity-manager.proxy.ts +++ b/packages/typeorm-common/src/proxies/entity-manager.proxy.ts @@ -7,8 +7,8 @@ import { TransactionProxy } from './transaction.proxy'; export class EntityManagerProxy { constructor(private _entityManager: EntityManager) {} - entityManager(options?: EntityManagerOptionInterface) { - return options?.entityManager ?? this._entityManager; + entityManager() { + return this._entityManager; } repository( @@ -17,8 +17,11 @@ export class EntityManagerProxy { ): Repository { if (options?.transaction) { return options.transaction.repository(repository); - } else if (this.entityManager(options) !== this._entityManager) { - return this._entityManager.withRepository>(repository); + } else if ( + options?.entityManager && + options?.entityManager !== repository.manager + ) { + return options.entityManager.withRepository>(repository); } else { return repository; }