Skip to content

Commit

Permalink
[Hotfix] query error(contains empty string) fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Han-Jeong committed May 31, 2024
1 parent a4c36ea commit 41fd31a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Page<Question> findQuestionsByKeyword(String keyword, Pageable pageable)
public Page<Question> findQuestionListByKeywordAndSortParam(String keyword, QuestionSortParam sortParam, Pageable pageable) {
JPAQuery<Question> baseQuery = queryFactory.selectFrom(question);
JPAQuery<Long> countQuery = queryFactory.select(question.count()).from(question);
if (keyword != null) {
if (!(keyword == null || keyword.isEmpty())) {
baseQuery.join(question.boardHashtags, boardHashtag)
.join(boardHashtag.hashtag, hashtag)
.where(hashtag.content.contains(keyword).or(question.title.contains(keyword)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Page<Siren> searchAndSortSirenList(String keyword,
Pageable pageable) {
JPAQuery<Siren> baseQuery = queryFactory.selectFrom(siren);
JPAQuery<Long> countQuery = queryFactory.select(siren.count()).from(siren);
if (keyword != null) {
if (!(keyword == null || keyword.isEmpty())) {
baseQuery.where(siren.title.contains(keyword));
countQuery.where(siren.title.contains(keyword));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Page<Story> findStoriesByKeyword(String keyword, Pageable pageable) {
public Page<Story> findStoryListByKeywordAndSortParam(String keyword, StorySortParam sortParam, Pageable pageable) {
JPAQuery<Story> baseQuery = queryFactory.selectFrom(story);
JPAQuery<Long> countQuery = queryFactory.select(story.count()).from(story);
if (keyword != null) {
if (!(keyword == null || keyword.isEmpty())) {
baseQuery.join(story.boardHashtags, boardHashtag)
.join(boardHashtag.hashtag, hashtag)
.where(hashtag.content.contains(keyword).or(story.content.contains(keyword)));
Expand Down

0 comments on commit 41fd31a

Please sign in to comment.