Skip to content

Commit

Permalink
Merge pull request #20 from qpfmtlcp/master
Browse files Browse the repository at this point in the history
fix: duplicate column selection
  • Loading branch information
rewiko authored Aug 24, 2022
2 parents 6a48357 + 638c629 commit 3613b1e
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 @@ -631,9 +631,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(select);
Expand Down Expand Up @@ -946,9 +948,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 select;
Expand Down

0 comments on commit 3613b1e

Please sign in to comment.