diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index 6ef92765b6..a3b813b96b 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -460,6 +460,10 @@ export class Database extends EventEmitter implements AsyncEmitter { } if (options.underscored) { + if (lodash.get(options, 'sortable.scopeKey')) { + options.sortable.scopeKey = snakeCase(options.sortable.scopeKey); + } + if (lodash.get(options, 'indexes')) { // change index fields to snake case options.indexes = options.indexes.map((index) => { diff --git a/packages/core/database/src/fields/sort-field.ts b/packages/core/database/src/fields/sort-field.ts index cbdf8ee5f8..da4a77fd3e 100644 --- a/packages/core/database/src/fields/sort-field.ts +++ b/packages/core/database/src/fields/sort-field.ts @@ -171,7 +171,6 @@ export class SortField extends Field { }; const scopeKey = this.options.scopeKey; - if (scopeKey) { const groups = await this.collection.repository.find({ attributes: [scopeKey],