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

@ -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 {