diff --git a/pkg/sqlcache/informer/listoption_indexer.go b/pkg/sqlcache/informer/listoption_indexer.go index 3dd3069b..412ab9ef 100644 --- a/pkg/sqlcache/informer/listoption_indexer.go +++ b/pkg/sqlcache/informer/listoption_indexer.go @@ -6,7 +6,6 @@ import ( "encoding/gob" "errors" "fmt" - "github.com/rancher/steve/pkg/sqlcache/sqltypes" "regexp" "sort" "strconv" diff --git a/pkg/sqlcache/informer/listoption_indexer_test.go b/pkg/sqlcache/informer/listoption_indexer_test.go index a79d41de..16255ecd 100644 --- a/pkg/sqlcache/informer/listoption_indexer_test.go +++ b/pkg/sqlcache/informer/listoption_indexer_test.go @@ -817,27 +817,6 @@ func TestListByOptions(t *testing.T) { expectedErr: nil, }) - tests = append(tests, testCase{ - description: "ListByOptions sorting when # fields != # sort orders should return an error", - listOptions: sqltypes.ListOptions{ - Sort: sqltypes.Sort{ - Fields: [][]string{{"metadata", "somefield"}, {"status", "someotherfield"}}, - Orders: []sqltypes.SortOrder{sqltypes.DESC, sqltypes.ASC, sqltypes.ASC}, - }, - }, - partitions: []partition.Partition{}, - ns: "", - expectedStmt: `SELECT o.object, o.objectnonce, o.dekid FROM "something" o - JOIN "something_fields" f ON o.key = f.key - WHERE - (FALSE) - ORDER BY f."metadata.somefield" DESC, f."status.someotherfield" ASC`, - returnList: []any{&unstructured.Unstructured{Object: unstrTestObjectMap}, &unstructured.Unstructured{Object: unstrTestObjectMap}}, - expectedList: &unstructured.UnstructuredList{Object: map[string]interface{}{"items": []map[string]interface{}{unstrTestObjectMap, unstrTestObjectMap}}, Items: []unstructured.Unstructured{{Object: unstrTestObjectMap}, {Object: unstrTestObjectMap}}}, - expectedContToken: "", - expectedErr: fmt.Errorf("sort fields length 2 != sort orders length 3"), - }) - tests = append(tests, testCase{ description: "ListByOptions with Pagination.PageSize set should set limit to PageSize in prepared sql.Stmt", listOptions: sqltypes.ListOptions{ diff --git a/pkg/sqlcache/sqltypes/types.go b/pkg/sqlcache/sqltypes/types.go index 98f5d9c4..6c052648 100644 --- a/pkg/sqlcache/sqltypes/types.go +++ b/pkg/sqlcache/sqltypes/types.go @@ -40,10 +40,10 @@ type ListOptions struct { // // If more than one value is given for the `Match` field, we do an "IN ()" test type Filter struct { - Field []string - Matches []string - Op Op - Partial bool + Field []string + Matches []string + Op Op + Partial bool } // OrFilter represents a set of possible fields to filter by, where an item may match any filter in the set to be included in the result. @@ -65,20 +65,10 @@ type SortList struct { SortDirectives []Sort } -type SortList struct { - SortDirectives []Sort -} - // Pagination represents how to return paginated results. type Pagination struct { PageSize int - Page int -} - -func NewSortList() *SortList { - return &SortList{ - SortDirectives: []Sort{}, - } + Page int } func NewSortList() *SortList {