Chore: cleanup entity api from CodeQL scan (#64277)

cleanup
This commit is contained in:
Ryan McKinley 2023-03-07 07:54:25 -08:00 committed by GitHub
parent 68df83c86d
commit bb9ae04bd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View File

@ -5,7 +5,7 @@ import "strings"
type selectQuery struct { type selectQuery struct {
fields []string // SELECT xyz fields []string // SELECT xyz
from string // FROM object from string // FROM object
limit int limit int64
oneExtra bool oneExtra bool
where []string where []string

View File

@ -749,7 +749,7 @@ func (s *sqlEntityServer) Search(ctx context.Context, r *entity.EntitySearchRequ
fields: fields, fields: fields,
from: "entity", // the table from: "entity", // the table
args: []interface{}{}, args: []interface{}{},
limit: int(r.Limit), limit: r.Limit,
oneExtra: true, // request one more than the limit (and show next token if it exists) oneExtra: true, // request one more than the limit (and show next token if it exists)
} }
entityQuery.addWhere("tenant_id", user.OrgID) entityQuery.addWhere("tenant_id", user.OrgID)
@ -780,11 +780,6 @@ func (s *sqlEntityServer) Search(ctx context.Context, r *entity.EntitySearchRequ
query, args := entityQuery.toQuery() query, args := entityQuery.toQuery()
fmt.Printf("\n\n-------------\n")
fmt.Printf("%s\n", query)
fmt.Printf("%v\n", args)
fmt.Printf("\n-------------\n\n")
rows, err := s.sess.Query(ctx, query, args...) rows, err := s.sess.Query(ctx, query, args...)
if err != nil { if err != nil {
return nil, err return nil, err
@ -820,7 +815,7 @@ func (s *sqlEntityServer) Search(ctx context.Context, r *entity.EntitySearchRequ
} }
// found one more than requested // found one more than requested
if len(rsp.Results) >= entityQuery.limit { if int64(len(rsp.Results)) >= entityQuery.limit {
// TODO? should this encode start+offset? // TODO? should this encode start+offset?
rsp.NextPageToken = oid rsp.NextPageToken = oid
break break