Skip to content

Commit

Permalink
Fix error when there are no categories
Browse files Browse the repository at this point in the history
  • Loading branch information
Alkemic committed Feb 18, 2021
1 parent 9d29d35 commit 1506d98
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions repository/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ func (r *feedRepository) Get(ctx context.Context, id int64) (Feed, error) {
}

func (r *feedRepository) ListForCategories(ctx context.Context, categoriesIDs []int64) ([]Feed, error) {
if len(categoriesIDs) == 0 {
return []Feed{}, nil
}

query, args, err := sqlx.In(selectFeedsForCategoriesQuery, categoriesIDs)
if err != nil {
return nil, fmt.Errorf("error preparing query 'in' values: %w", err)
}
feeds := []Feed{}
if err = r.db.SelectContext(ctx, &feeds, r.db.Rebind(query), args...); err != nil {
return nil, fmt.Errorf("cannot select feeds: %w", err)
Expand Down

0 comments on commit 1506d98

Please sign in to comment.