mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix inner query sort limit (#16922)
* Add sort within inner query * Run tests for all vendors * Apply limit to all queries * Enable sorting in MSSQL subquery by setting a limit * Add tests * Parse function field names for a2o * Improve order string spacing * Update unit test * Fix mysql5 tests * Revert testing for all vendors * Extract original collection name * Add comment for MSSQL applyLimit helper Co-authored-by: Brainslug <br41nslug@users.noreply.github.com>
This commit is contained in:
@@ -43,9 +43,7 @@ export default function applyQuery(
|
||||
applySort(knex, schema, dbQuery, query.sort, collection, aliasMap);
|
||||
}
|
||||
|
||||
if (!options?.hasMultiRelationalSort) {
|
||||
applyLimit(dbQuery, query.limit);
|
||||
}
|
||||
applyLimit(knex, dbQuery, query.limit);
|
||||
|
||||
if (query.offset) {
|
||||
applyOffset(knex, dbQuery, query.offset);
|
||||
@@ -311,9 +309,9 @@ export function applySort(
|
||||
rootQuery.orderBy(sortRecords);
|
||||
}
|
||||
|
||||
export function applyLimit(rootQuery: Knex.QueryBuilder, limit: any) {
|
||||
if (typeof limit === 'number' && limit !== -1) {
|
||||
rootQuery.limit(limit);
|
||||
export function applyLimit(knex: Knex, rootQuery: Knex.QueryBuilder, limit: any) {
|
||||
if (typeof limit === 'number') {
|
||||
getHelpers(knex).schema.applyLimit(rootQuery, limit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user