mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
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:
parent
e6c48a5228
commit
19b3899a5c
12 changed files with 206 additions and 168 deletions
|
@ -144,7 +144,7 @@ func (r *NotificationRepo) FindByID(ctx context.Context, id int) (*domain.Notifi
|
|||
"updated_at",
|
||||
).
|
||||
From("notification").
|
||||
Where("id = ?", id)
|
||||
Where(sq.Eq{"id": id})
|
||||
|
||||
query, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
|
@ -240,7 +240,7 @@ func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notif
|
|||
Set("api_key", apiKey).
|
||||
Set("channel", channel).
|
||||
Set("updated_at", sq.Expr("CURRENT_TIMESTAMP")).
|
||||
Where("id = ?", notification.ID)
|
||||
Where(sq.Eq{"id": notification.ID})
|
||||
|
||||
query, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
|
@ -260,7 +260,7 @@ func (r *NotificationRepo) Update(ctx context.Context, notification domain.Notif
|
|||
func (r *NotificationRepo) Delete(ctx context.Context, notificationID int) error {
|
||||
queryBuilder := r.db.squirrel.
|
||||
Delete("notification").
|
||||
Where("id = ?", notificationID)
|
||||
Where(sq.Eq{"id": notificationID})
|
||||
|
||||
query, args, err := queryBuilder.ToSql()
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue