internal/authtoken: use simpler query arg

This commit is contained in:
Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:21 -08:00
1 parent 9b40cf0801
commit 61642f8b5f
1 file changed
+4 -20
+4 -20
View File
@@ -7,8 +7,6 @@ import (
"context"
"database/sql"
"fmt"
"strconv"
"strings"
"time"
"github.com/golang/protobuf/ptypes"
@@ -308,15 +306,8 @@ func (r *Repository) listAuthTokens(ctx context.Context, withScopeIds []string,
limit = opts.withLimit
}
var args []any
var inClauses []string
for i, scopeId := range withScopeIds {
arg := "scope_id_" + strconv.Itoa(i)
inClauses = append(inClauses, "@"+arg)
args = append(args, sql.Named(arg, scopeId))
}
inClause := strings.Join(inClauses, ", ")
whereClause := "scope_id in (" + inClause + ")"
args := []any{sql.Named("scope_ids", withScopeIds)}
whereClause := "scope_id in @scope_ids"
query := fmt.Sprintf(listAuthTokensTemplate, limit, whereClause)
if opts.withStartPageAfterItem != nil {
@@ -351,15 +342,8 @@ func (r *Repository) listAuthTokensRefresh(ctx context.Context, updatedAfter tim
limit = opts.withLimit
}
var args []any
var inClauses []string
for i, scopeId := range withScopeIds {
arg := "scope_id_" + strconv.Itoa(i)
inClauses = append(inClauses, "@"+arg)
args = append(args, sql.Named(arg, scopeId))
}
inClause := strings.Join(inClauses, ", ")
whereClause := "scope_id in (" + inClause + ")"
args := []any{sql.Named("scope_ids", withScopeIds)}
whereClause := "scope_id in @scope_ids"
query := fmt.Sprintf(refreshAuthTokensTemplate, limit, whereClause)
args = append(args,