refactor(database): clean-up queries (#569)

* fix(database): build WHERE using squirrel

* flip LIKEs

* change sql.LevelReadCommitted

* feat(db): add missing commits

* implement single query for releases

* cleanup

* feat(releases): properly handle limit for Find

* feat(releases): make dynamic ILike helper

* feat(releases): check for empty ReleaseActionStatus

* add values as sql.NullX
* check if ID is non 0

* feat(releases): improve find
This commit is contained in:
Kyle Sanderson 2022-12-30 14:53:45 -08:00 committed by GitHub
parent e6c48a5228
commit 19b3899a5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 206 additions and 168 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/autobrr/autobrr/internal/logger"
"github.com/autobrr/autobrr/pkg/errors"
sq "github.com/Masterminds/squirrel"
"github.com/lib/pq"
"github.com/rs/zerolog"
)
@ -55,7 +56,7 @@ func (r *APIRepo) Store(ctx context.Context, key *domain.APIKey) error {
func (r *APIRepo) Delete(ctx context.Context, key string) error {
queryBuilder := r.db.squirrel.
Delete("api_key").
Where("key = ?", key)
Where(sq.Eq{"key": key})
query, args, err := queryBuilder.ToSql()
if err != nil {