1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-06 01:41:00 +00:00

Sort labels (#527)

* Support sorting on metadata.labels.NAME

The key to doing this is if we want to sort on, say, `metadata.labels.foo`, we need to
search for all rows with a label of the name `foo` in all the various
join tables we create for each label the query references.

We ignore nulls by giving them lowest priority using "NULLS LAST"
("NULLS FIRST" if sorting in descending order).

* Ensure labels that are mentioned only in sort params are still selected.

If we don't do this -- say we sort on metadata.labels.foo but never
make a test on it, the sort resuilts are ignored.

* Remove extraneous debugger statements.
This commit is contained in:
Eric Promislow
2025-03-04 09:30:14 -08:00
committed by GitHub
parent a85993129e
commit 0edba0da3e
3 changed files with 294 additions and 26 deletions

View File

@@ -177,7 +177,7 @@ func TestAfterUpsert(t *testing.T) {
deleteIndicesStmt := NewMockStmt(gomock.NewController(t))
addIndexStmt := NewMockStmt(gomock.NewController(t))
indexer := &Indexer{
ctx: context.Background(),
ctx: context.Background(),
Store: store,
indexers: map[string]cache.IndexFunc{
"a": func(obj interface{}) ([]string, error) {
@@ -200,7 +200,7 @@ func TestAfterUpsert(t *testing.T) {
objKey := "key"
deleteIndicesStmt := NewMockStmt(gomock.NewController(t))
indexer := &Indexer{
ctx: context.Background(),
ctx: context.Background(),
Store: store,
indexers: map[string]cache.IndexFunc{
@@ -223,7 +223,7 @@ func TestAfterUpsert(t *testing.T) {
addIndexStmt := NewMockStmt(gomock.NewController(t))
objKey := "key"
indexer := &Indexer{
ctx: context.Background(),
ctx: context.Background(),
Store: store,
indexers: map[string]cache.IndexFunc{
"a": func(obj interface{}) ([]string, error) {