diff --git a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts index bf5c7f8242..53e30e663e 100644 --- a/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/service/DefaultEntitiesCatalog.ts @@ -356,8 +356,7 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog { ...cursor.sortFields[0], }; - const [sortFieldValue, metadataSortFieldValue] = - cursor.sortFieldValues || []; + const [prevItemSortFieldValue, prevItemUid] = cursor.sortFieldValues || []; const dbQuery = db('search') .join('final_entities', 'search.entity_id', 'final_entities.entity_id') @@ -379,17 +378,17 @@ export class DefaultEntitiesCatalog implements EntitiesCatalog { const isOrderingDescending = sortField.order === 'desc'; - if (sortFieldValue) { + if (prevItemSortFieldValue) { dbQuery.andWhere( 'value', isFetchingBackwards !== isOrderingDescending ? '<' : '>', - sortFieldValue, + prevItemSortFieldValue, ); dbQuery.orWhere(function nested() { - this.where('value', '=', sortFieldValue).andWhere( + this.where('value', '=', prevItemSortFieldValue).andWhere( 'search.entity_id', isFetchingBackwards !== isOrderingDescending ? '<' : '>', - metadataSortFieldValue, + prevItemUid, ); }); }