Skip to content

Commit

Permalink
Return an error if # sort-fields != # sort-orders
Browse files Browse the repository at this point in the history
  • Loading branch information
ericpromislow committed Jan 15, 2025
1 parent ef7ae55 commit 559627d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cache/sql/informer/listoption_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ func (l *ListOptionIndexer) ListByOptions(ctx context.Context, lo ListOptions, p
}

// 2- Sorting: ORDER BY clauses (from lo.Sort)
if len(lo.Sort.Fields) != len(lo.Sort.Orders) {
return nil, 0, "", fmt.Errorf("sort fields length %d != sort orders length %d", len(lo.Sort.Fields), len(lo.Sort.Orders))
}
if len(lo.Sort.Fields) > 0 {
orderByClauses := []string{}
for i, field := range lo.Sort.Fields {
Expand Down

0 comments on commit 559627d

Please sign in to comment.