Skip to content

Commit

Permalink
Merge pull request nestjsx#511 from nestjsx/fix/typeorm-join-select
Browse files Browse the repository at this point in the history
fix(typeorm): fixed join select fields
  • Loading branch information
michaelyali authored May 14, 2020
2 parents 651ee4e + b19f50e commit 33a69e5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/crud-typeorm/src/typeorm-crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,16 @@ export class TypeOrmCrudService<T> extends CrudService<T> {
builder[relationType](allowedRelation.path, alias);

if (options.select !== false) {
const columns = isArrayFull(cond.select)
? cond.select.filter((column) =>
allowedRelation.allowedColumns.some((allowed) => allowed === column),
)
: allowedRelation.allowedColumns;

const select = [
...allowedRelation.primaryColumns,
...(options.persist && options.persist.length ? options.persist : []),
...allowedRelation.allowedColumns,
...(isArrayFull(options.persist) ? options.persist : []),
...columns,
].map((col) => `${alias}.${col}`);

builder.addSelect(select);
Expand Down

0 comments on commit 33a69e5

Please sign in to comment.