Skip to content

Commit

Permalink
fix(vault): offset in sql query
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Jan 28, 2024
1 parent 0a31f76 commit 84fdfa4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions db/sql/SqlDb.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ func (d *SqlDb) getObjects(projectID int, props db.ObjectProps, params db.Retrie
q = q.OrderBy("pe." + orderColumn + " " + orderDirection)
}

if params.Count > 0 {
q = q.Limit(uint64(params.Count))
}

if params.Offset > 0 {
q = q.Offset(uint64(params.Offset))
}

query, args, err := q.ToSql()

if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion db/sql/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sql

import (
"database/sql"
"errors"
"github.com/ansible-semaphore/semaphore/db"
)

Expand Down Expand Up @@ -115,7 +116,7 @@ func (d *SqlDb) RekeyAccessKeys(oldKey string) (err error) {
key.OverrideSecret = true
err = d.UpdateAccessKey(key)

if err != nil {
if err != nil && !errors.Is(err, db.ErrNotFound) {
return err
}
}
Expand Down

0 comments on commit 84fdfa4

Please sign in to comment.