Skip to content

Commit

Permalink
Merge pull request #34 from ZaidMaslouhi/master
Browse files Browse the repository at this point in the history
Fix: duplicate column selection issue in getMany with joins and pagination
  • Loading branch information
zaro authored Mar 21, 2024
2 parents 5008444 + 5333edd commit b88f8ff
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions packages/crud-typeorm/src/typeorm-crud.service.ts
Original file line number Diff line number Diff line change
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 b88f8ff

Please sign in to comment.