mirror of
https://github.com/directus/directus.git
synced 2026-02-14 00:05:18 -05:00
Fix sort added by offset not removed for MSSQL (#17343)
This commit is contained in:
@@ -39,10 +39,6 @@ export default function applyQuery(
|
||||
const aliasMap: AliasMap = options?.aliasMap ?? Object.create(null);
|
||||
let hasMultiRelationalFilter = false;
|
||||
|
||||
if (query.sort && !options?.isInnerQuery && !options?.hasMultiRelationalSort) {
|
||||
applySort(knex, schema, dbQuery, query.sort, collection, aliasMap);
|
||||
}
|
||||
|
||||
applyLimit(knex, dbQuery, query.limit);
|
||||
|
||||
if (query.offset) {
|
||||
@@ -50,7 +46,11 @@ export default function applyQuery(
|
||||
}
|
||||
|
||||
if (query.page && query.limit && query.limit !== -1) {
|
||||
dbQuery.offset(query.limit * (query.page - 1));
|
||||
applyOffset(knex, dbQuery, query.limit * (query.page - 1));
|
||||
}
|
||||
|
||||
if (query.sort && !options?.isInnerQuery && !options?.hasMultiRelationalSort) {
|
||||
applySort(knex, schema, dbQuery, query.sort, collection, aliasMap);
|
||||
}
|
||||
|
||||
if (query.search) {
|
||||
@@ -306,6 +306,9 @@ export function applySort(
|
||||
|
||||
if (returnRecords) return { sortRecords, hasMultiRelationalSort };
|
||||
|
||||
// Clears the order if any, eg: from MSSQL offset
|
||||
rootQuery.clear('order');
|
||||
|
||||
rootQuery.orderBy(sortRecords);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user