diff --git a/src/domain-services/flows/flow-service.ts b/src/domain-services/flows/flow-service.ts index 02c44a53..064feee1 100644 --- a/src/domain-services/flows/flow-service.ts +++ b/src/domain-services/flows/flow-service.ts @@ -171,21 +171,25 @@ export class FlowService { let joinQuery = dbConnection .queryBuilder() .distinct('flowObject.flowID', 'flowObject.versionID') - .from('flowObject') - .where('objectType', entityCondKeyFlowObjectType); + .from('flowObject'); if (result._tag === 'Right') { joinQuery = joinQuery .join(entity, 'flowObject.objectID', `${entity}.id`) - .select(mappedOrderBy.column) + .select(`${entity}.${mappedOrderBy.column}`) // This is needed since we must select the column to order by + .where('objectType', entityCondKeyFlowObjectType) .orderBy(mappedOrderBy.column, mappedOrderBy.order); } else { // Collect fisrt part of the entity key by the fisrt Case letter const entityKey = entity.slice(0, entity.search(/[A-Z]/)); - joinQuery = joinQuery - .join(orderBy.entity, 'flowObject.objectID', `${entityKey}Id`) - .select(mappedOrderBy.column) + .join( + orderBy.entity, + 'flowObject.objectID', + `${orderBy.entity}.${entityKey}Id` + ) + .select(`${orderBy.entity}.${mappedOrderBy.column}`) // This is needed since we must select the column to order by + .where('objectType', entityKey) .orderBy(mappedOrderBy.column, mappedOrderBy.order); } diff --git a/src/domain-services/flows/strategy/impl/search-flow-by-filters-strategy-impl.ts b/src/domain-services/flows/strategy/impl/search-flow-by-filters-strategy-impl.ts index c86cd0f4..e5f68f4c 100644 --- a/src/domain-services/flows/strategy/impl/search-flow-by-filters-strategy-impl.ts +++ b/src/domain-services/flows/strategy/impl/search-flow-by-filters-strategy-impl.ts @@ -55,6 +55,7 @@ export class SearchFlowByFiltersStrategy implements FlowSearchStrategy { const sortByFlowIDs: UniqueFlowEntity[] = []; if (isSortByEntity) { + console.log('HERE'); // Get the flowIDs using the orderBy entity const flowIDsFromSortingEntity: UniqueFlowEntity[] = await this.flowService.getFlowIDsFromEntity(