Revert "fix: unified resource server list queries order column" (#109529)
This commit is contained in:
@@ -599,7 +599,7 @@ func (b *backend) listLatest(ctx context.Context, req *resourcepb.ListRequest, c
|
||||
return 0, fmt.Errorf("only works for the 'latest' resource version")
|
||||
}
|
||||
|
||||
iter := &listIter{}
|
||||
iter := &listIter{sortAsc: false}
|
||||
err := b.db.WithTx(ctx, ReadCommittedRO, func(ctx context.Context, tx db.Tx) error {
|
||||
var err error
|
||||
iter.listRV, err = b.fetchLatestRV(ctx, tx, b.dialect, req.Options.Key.Group, req.Options.Key.Resource)
|
||||
@@ -637,7 +637,7 @@ func (b *backend) listAtRevision(ctx context.Context, req *resourcepb.ListReques
|
||||
defer span.End()
|
||||
|
||||
// Get the RV
|
||||
iter := &listIter{listRV: req.ResourceVersion}
|
||||
iter := &listIter{listRV: req.ResourceVersion, sortAsc: false}
|
||||
if req.NextPageToken != "" {
|
||||
continueToken, err := resource.GetContinueToken(req.NextPageToken)
|
||||
if err != nil {
|
||||
|
||||
@@ -29,7 +29,7 @@ WHERE 1 = 1
|
||||
AND {{ .Ident "resource_version" }} = {{ .Arg .ExactRV }}
|
||||
{{ end }}
|
||||
{{ if .SortAscending }}
|
||||
ORDER BY {{ .Ident "resource_version" }} ASC
|
||||
ORDER BY resource_version ASC
|
||||
{{ else }}
|
||||
ORDER BY {{ .Ident "resource_version" }} DESC
|
||||
ORDER BY resource_version DESC
|
||||
{{ end }}
|
||||
|
||||
@@ -50,7 +50,7 @@ SELECT
|
||||
AND kv.{{ .Ident "name" }} = {{ .Arg .Request.Options.Key.Name }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
ORDER BY kv.{{ .Ident "resource_version" }} ASC
|
||||
ORDER BY kv.{{ .Ident "namespace" }} ASC, kv.{{ .Ident "name" }} ASC
|
||||
{{ if (gt .Request.Limit 0) }}
|
||||
LIMIT {{ .Arg .Request.Limit }} OFFSET {{ .Arg .Request.Offset }}
|
||||
{{ end }}
|
||||
|
||||
@@ -23,5 +23,5 @@ SELECT
|
||||
AND {{ .Ident "name" }} = {{ .Arg .Request.Options.Key.Name }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
ORDER BY {{ .Ident "resource_version" }} ASC
|
||||
ORDER BY {{ .Ident "namespace" }} ASC, {{ .Ident "name" }} ASC
|
||||
;
|
||||
|
||||
@@ -242,13 +242,10 @@ func (r *resourceHistoryReadLatestRVResponse) Results() (*resourceHistoryReadLat
|
||||
}
|
||||
|
||||
type historyListRequest struct {
|
||||
ResourceVersion int64
|
||||
Limit int64
|
||||
Offset int64
|
||||
Folder string
|
||||
Options *resourcepb.ListOptions
|
||||
ResourceVersion, Limit, Offset int64
|
||||
Folder string
|
||||
Options *resourcepb.ListOptions
|
||||
}
|
||||
|
||||
type sqlResourceHistoryListRequest struct {
|
||||
sqltemplate.SQLTemplate
|
||||
Request *historyListRequest
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ WHERE 1 = 1
|
||||
AND `group` = 'gg'
|
||||
AND `resource` = 'rr'
|
||||
AND `name` = 'name'
|
||||
ORDER BY `resource_version` DESC
|
||||
ORDER BY resource_version DESC
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ SELECT
|
||||
AND maxkv.`name` = kv.`name`
|
||||
WHERE kv.`action` != 3
|
||||
AND kv.`namespace` = 'ns'
|
||||
ORDER BY kv.`resource_version` ASC
|
||||
ORDER BY kv.`namespace` ASC, kv.`name` ASC
|
||||
LIMIT 10 OFFSET 0
|
||||
;
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ SELECT
|
||||
FROM `resource`
|
||||
WHERE 1 = 1
|
||||
AND `namespace` = 'ns'
|
||||
ORDER BY `resource_version` ASC
|
||||
ORDER BY `namespace` ASC, `name` ASC
|
||||
;
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ WHERE 1 = 1
|
||||
AND "group" = 'gg'
|
||||
AND "resource" = 'rr'
|
||||
AND "name" = 'name'
|
||||
ORDER BY "resource_version" DESC
|
||||
ORDER BY resource_version DESC
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ SELECT
|
||||
AND maxkv."name" = kv."name"
|
||||
WHERE kv."action" != 3
|
||||
AND kv."namespace" = 'ns'
|
||||
ORDER BY kv."resource_version" ASC
|
||||
ORDER BY kv."namespace" ASC, kv."name" ASC
|
||||
LIMIT 10 OFFSET 0
|
||||
;
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ SELECT
|
||||
FROM "resource"
|
||||
WHERE 1 = 1
|
||||
AND "namespace" = 'ns'
|
||||
ORDER BY "resource_version" ASC
|
||||
ORDER BY "namespace" ASC, "name" ASC
|
||||
;
|
||||
|
||||
+1
-1
@@ -13,4 +13,4 @@ WHERE 1 = 1
|
||||
AND "group" = 'gg'
|
||||
AND "resource" = 'rr'
|
||||
AND "name" = 'name'
|
||||
ORDER BY "resource_version" DESC
|
||||
ORDER BY resource_version DESC
|
||||
|
||||
+1
-1
@@ -24,6 +24,6 @@ SELECT
|
||||
AND maxkv."name" = kv."name"
|
||||
WHERE kv."action" != 3
|
||||
AND kv."namespace" = 'ns'
|
||||
ORDER BY kv."resource_version" ASC
|
||||
ORDER BY kv."namespace" ASC, kv."name" ASC
|
||||
LIMIT 10 OFFSET 0
|
||||
;
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ SELECT
|
||||
FROM "resource"
|
||||
WHERE 1 = 1
|
||||
AND "namespace" = 'ns'
|
||||
ORDER BY "resource_version" ASC
|
||||
ORDER BY "namespace" ASC, "name" ASC
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user