1
0
Fork 0
mirror of synced 2024-08-31 01:31:18 +12:00

Ensure all search requests specify a sort field to avoid random sorting

This commit is contained in:
Andrew Kingston 2022-11-17 14:15:24 +00:00
parent e8b993b14c
commit ce9feed5f2

View file

@ -117,7 +117,7 @@ export default class DataFetch {
* Fetches a fresh set of data from the server, resetting pagination
*/
async getInitialData() {
const { datasource, filter, sortColumn, paginate } = this.options
const { datasource, filter, paginate } = this.options
// Fetch datasource definition and determine feature flags
const definition = await this.getDefinition(datasource)
@ -135,6 +135,17 @@ export default class DataFetch {
return
}
// If no sort order, default to descending
if (!this.options.sortOrder) {
this.options.sortOrder = "ascending"
}
// If no sort column, use the first field in the schema
if (!this.options.sortColumn) {
this.options.sortColumn = Object.keys(schema)[0]
}
const { sortColumn } = this.options
// Determine what sort type to use
let sortType = "string"
if (sortColumn) {