Skip to content

Commit

Permalink
fix: 🐛 remove duplication within the selected columns array
Browse files Browse the repository at this point in the history
issue #32
  • Loading branch information
ZaidMaslouhi committed Mar 20, 2024
1 parent 5008444 commit 5333edd
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/crud-typeorm/src/typeorm-crud.service.ts
Expand Up @@ -647,9 +647,11 @@ export class TypeOrmCrudService<T> extends CrudService<T, DeepPartial<T>> {
: 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(Array.from(new Set(select)));
Expand Down Expand Up @@ -985,9 +987,11 @@ export class TypeOrmCrudService<T> extends CrudService<T, DeepPartial<T>> {
: 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 Array.from(new Set(select));
Expand Down

0 comments on commit 5333edd

Please sign in to comment.