Skip to content

Commit

Permalink
refactor: fix descending on single condition
Browse files Browse the repository at this point in the history
  • Loading branch information
geoje committed Sep 27, 2024
1 parent 9b02264 commit 500c257
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface RecipeRepository extends JpaRepository<Recipe, Long> {
SELECT DISTINCT recipe.id
FROM CategoryRecipe
WHERE category.name = :category
ORDER BY recipe.id DESC
""")
List<Long> findRecipeIdsByCategory(Pageable pageable, String category);

Expand All @@ -24,6 +25,7 @@ public interface RecipeRepository extends JpaRepository<Recipe, Long> {
FROM Recipe
WHERE title LIKE CONCAT('%', :keyword, '%')
OR description LIKE CONCAT('%', :keyword, '%')
ORDER BY id DESC
""")
List<Long> findRecipeIdsByKeyword(Pageable pageable, String keyword);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void findRecipeIdsByCategory() {
List<Long> recipeIds = repository.findRecipeIdsByCategory(pageable, category);

// then
assertThat(recipeIds).containsExactly(2L, 3L, 7L);
assertThat(recipeIds).contains(15L, 14L, 9L);
}

@Test
Expand All @@ -47,7 +47,7 @@ void findRecipeIdsByKeyword() {
List<Long> recipeIds = repository.findRecipeIdsByKeyword(pageable, keyword);

// then
assertThat(recipeIds).containsExactly(11L, 12L);
assertThat(recipeIds).containsExactly(12L, 11L);
}

@Test
Expand Down

0 comments on commit 500c257

Please sign in to comment.