Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ describe('GetAll methode test', () => {
expect(result.meta.totalItems).toBe(0);
expect(result.meta.pageSize).toBe(page.size);

expect(resultJoinSpy).toBeCalledTimes(4);
expect(resultJoinSpy).toBeCalledTimes(2);
expect(resultJoinSpy).toHaveBeenNthCalledWith(
1,
`${aliasString}.${include[0]}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,24 @@ export async function getAll<T>(
const resultBuilder = resultBuilderQuery
.select([...fieldsSelect])
const ids = resultIds.map((i) => i[`${countAlias}_${primaryColumn}`]);
let result = [];
if (ids.length > 0) {
resultBuilder.whereInIds(resultIds.map((i) => i[`${countAlias}_${primaryColumn}`]));
}

for (let i = 0; i < expressionObjectForRelation.length; i++) {
const {expression, params, selectInclude} =
expressionObjectForRelation[i];
if (selectInclude && !(include || []).includes(selectInclude as any)) {
resultBuilder.leftJoin(
`${preparedResourceName}.${selectInclude}`,
selectInclude
);
}
if (i === 0 && ids.length === 0) {
resultBuilder.where(expression);
} else {
for (let i = 0; i < expressionObjectForRelation.length; i++) {
const {expression, params, selectInclude} =
expressionObjectForRelation[i];
if (selectInclude && !(include || []).includes(selectInclude as any)) {
resultBuilder.leftJoin(
`${preparedResourceName}.${selectInclude}`,
selectInclude
);
}
resultBuilder.andWhere(expression);
resultBuilder.setParameters(params ? {[params.name]: params.val} : {});
}

resultBuilder.setParameters(params ? {[params.name]: params.val} : {});
}

const result = await resultBuilder.getRawMany();
result = await resultBuilder.getRawMany();

const callQuery = Date.now() - startTime;

Expand Down