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; }