Skip to content

Commit 780d62a

Browse files
Merge pull request #19 from ConductorOne/goldschmidt-fix-grant-group
fix: grant group
2 parents f5e6bdb + 2be388e commit 780d62a

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ linters:
7272
- bodyclose # checks whether HTTP response body is closed successfully
7373
- durationcheck # check for two durations multiplied together
7474
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
75-
- execinquery # execinquery is a linter about query string checker in Query function which reads your Go src files and warning it finds
7675
- exhaustive # check exhaustiveness of enum switch statements
7776
- exportloopref # checks for pointers to enclosing loop variables
7877
- forbidigo # Forbids identifiers

pkg/client/group.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,7 @@ func (c *Client) GetGroupMember(ctx context.Context, groupID, userID int64) (*Gr
279279
args = append(args, userID)
280280

281281
sb := &strings.Builder{}
282-
_, err := sb.WriteString(`SELECT "id", "userId", "groupId", "isAdmin" FROM user_groups WHERE "groupId"=$1 AND "userId"=$2`)
283-
if err != nil {
284-
return nil, err
285-
}
286-
_, err = sb.WriteString("LIMIT 1")
282+
_, err := sb.WriteString(`SELECT "id", "userId", "groupId", "isAdmin" FROM user_groups WHERE "groupId"=$1 AND "userId"=$2 LIMIT 1`)
287283
if err != nil {
288284
return nil, err
289285
}
@@ -309,13 +305,8 @@ func (c *Client) AddGroupMember(ctx context.Context, groupID, userID int64, isAd
309305
l.Debug("add user to group", zap.Int64("user_id", userID))
310306

311307
args := []interface{}{groupID, userID, isAdmin}
312-
sb := &strings.Builder{}
313-
_, err := sb.WriteString(`INSERT INTO user_groups ("groupId", "userId", "isAdmin", "createdAt", "updatedAt") VALUES ($1, $2, $3, NOW(), NOW())`)
314-
if err != nil {
315-
return err
316-
}
317308

318-
if _, err := c.db.Exec(ctx, sb.String(), args...); err != nil {
309+
if _, err := c.db.Exec(ctx, `INSERT INTO user_groups ("groupId", "userId", "isAdmin", "createdAt", "updatedAt") VALUES ($1, $2, $3, NOW(), NOW())`, args...); err != nil {
319310
return err
320311
}
321312

0 commit comments

Comments
 (0)