Better SanitizeWhereClause

This commit is contained in:
Hein
2025-11-21 11:42:01 +02:00
parent 9a3564f05f
commit 02c9b96b0c
4 changed files with 330 additions and 6 deletions

View File

@@ -267,6 +267,12 @@ func (h *Handler) parseOptionsFromHeaders(r common.Request, model interface{}) E
h.resolveRelationNamesInOptions(&options, model)
}
//Always sort according to the primary key if no sorting is specified
if len(options.Sort) == 0 {
pkName := reflection.GetPrimaryKeyName(model)
options.Sort = []common.SortOption{{Column: pkName, Direction: "ASC"}}
}
return options
}