diff --git a/pkg/storage/unified/sql/backend.go b/pkg/storage/unified/sql/backend.go index b91f20a7a7f..a8a4750e86b 100644 --- a/pkg/storage/unified/sql/backend.go +++ b/pkg/storage/unified/sql/backend.go @@ -446,7 +446,7 @@ func (b *backend) poll(ctx context.Context, since int64, stream chan<- *resource pollReq := sqlResourceHistoryPollRequest{ SQLTemplate: sqltemplate.New(b.sqlDialect), SinceResourceVersion: since, - historyPollResponse: new(historyPollResponse), + Response: new(historyPollResponse), } query, err := sqltemplate.Execute(sqlResourceHistoryPoll, pollReq) if err != nil { @@ -465,7 +465,7 @@ func (b *backend) poll(ctx context.Context, since int64, stream chan<- *resource if err := rows.Scan(pollReq.GetScanDest()...); err != nil { return 0, fmt.Errorf("scan row #%d polling for resource history: %w", i, err) } - resp := *pollReq.historyPollResponse + resp := pollReq.Response next = resp.ResourceVersion stream <- &resource.WrittenEvent{ diff --git a/pkg/storage/unified/sql/data/resource_history_poll.sql b/pkg/storage/unified/sql/data/resource_history_poll.sql index 876c0023f90..8c6b0391800 100644 --- a/pkg/storage/unified/sql/data/resource_history_poll.sql +++ b/pkg/storage/unified/sql/data/resource_history_poll.sql @@ -1,11 +1,11 @@ SELECT - {{ .Ident "resource_version" | .Into .ResourceVersion }}, - {{ .Ident "namespace" | .Into .Key.Namespace }}, - {{ .Ident "group" | .Into .Key.Group }}, - {{ .Ident "resource" | .Into .Key.Resource }}, - {{ .Ident "name" | .Into .Key.Name }}, - {{ .Ident "value" | .Into .Value }}, - {{ .Ident "action" | .Into .Action }} + {{ .Ident "resource_version" | .Into .Response.ResourceVersion }}, + {{ .Ident "namespace" | .Into .Response.Key.Namespace }}, + {{ .Ident "group" | .Into .Response.Key.Group }}, + {{ .Ident "resource" | .Into .Response.Key.Resource }}, + {{ .Ident "name" | .Into .Response.Key.Name }}, + {{ .Ident "value" | .Into .Response.Value }}, + {{ .Ident "action" | .Into .Response.Action }} FROM {{ .Ident "resource_history" }} WHERE {{ .Ident "resource_version" }} > {{ .Arg .SinceResourceVersion }} diff --git a/pkg/storage/unified/sql/queries.go b/pkg/storage/unified/sql/queries.go index 91177527af3..2d625190a3c 100644 --- a/pkg/storage/unified/sql/queries.go +++ b/pkg/storage/unified/sql/queries.go @@ -106,7 +106,7 @@ func (r *historyPollResponse) Results() (*historyPollResponse, error) { type sqlResourceHistoryPollRequest struct { *sqltemplate.SQLTemplate SinceResourceVersion int64 - *historyPollResponse + Response *historyPollResponse } func (r sqlResourceHistoryPollRequest) Validate() error {