From ad767a3c1c39cd5d36a29654dedd8f4544a9440e Mon Sep 17 00:00:00 2001 From: ChengLei Shao Date: Thu, 10 Oct 2024 14:45:06 +0800 Subject: [PATCH] fix: default sort with multi filter target keys (#5383) --- packages/core/database/src/options-parser.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/core/database/src/options-parser.ts b/packages/core/database/src/options-parser.ts index 5ac11a3b17..c91df65456 100644 --- a/packages/core/database/src/options-parser.ts +++ b/packages/core/database/src/options-parser.ts @@ -140,6 +140,10 @@ export class OptionsParser { let defaultSortField = this.model.primaryKeyAttribute; + if (Array.isArray(this.collection.filterTargetKey) && this.collection.filterTargetKey.length == 1) { + defaultSortField = this.collection.filterTargetKey[0]; + } + if (!defaultSortField && this.collection.filterTargetKey && !Array.isArray(this.collection.filterTargetKey)) { defaultSortField = this.collection.filterTargetKey; }