diff --git a/packages/crud-typeorm/src/typeorm-crud.service.ts b/packages/crud-typeorm/src/typeorm-crud.service.ts index 5099a437..024bda63 100644 --- a/packages/crud-typeorm/src/typeorm-crud.service.ts +++ b/packages/crud-typeorm/src/typeorm-crud.service.ts @@ -631,9 +631,11 @@ export class TypeOrmCrudService extends CrudService> { : allowedRelation.allowedColumns; const select = [ - ...allowedRelation.primaryColumns, - ...(isArrayFull(options.persist) ? options.persist : []), - ...columns, + ...new Set([ + ...allowedRelation.primaryColumns, + ...(isArrayFull(options.persist) ? options.persist : []), + ...columns, + ]), ].map((col) => `${alias}.${col}`); builder.addSelect(select); @@ -946,9 +948,11 @@ export class TypeOrmCrudService extends CrudService> { : allowed; const select = [ - ...(options.persist && options.persist.length ? options.persist : []), - ...columns, - ...this.entityPrimaryColumns, + ...new Set([ + ...(options.persist && options.persist.length ? options.persist : []), + ...columns, + ...this.entityPrimaryColumns, + ]), ].map((col) => `${this.alias}.${col}`); return select;