Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix : 그룹이 없는 경우 예외 처리 #613 #614

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

seokho-1116
Copy link
Collaborator

@seokho-1116 seokho-1116 commented Aug 5, 2024

작업 내용 (Content)

  • 그룹이 없는 경우 예외 처리
  • 그룹 아이디가 없는 경우에 QueryDSL에서 빈 컬렉션에 대한 IN()1=2 이런식으로 where절에 추가되어서 쿼리 생성
  • 그 이유는 어떤 값이 공집합에 포함될 수 없기 때문에 내부적으로 빈 컬렉션에 대한 IN1=2와 같이 쿼리를 찍어냄(com.querydsl.jpa.JPQLSerialzier.java 517~519라인)
    Screenshot from 2024-08-05 22-55-13
select c1_0.`capsule_id`,
       c2_0.`image_url`,
       c1_0.`due_date`,
       g1_0.`group_id`,
       g1_0.`group_name`,
       g1_0.`group_profile_url`,
       m1_0.`nickname`,
       m1_0.`profile_url`,
       c1_0.`created_at`,
       c1_0.`point`,
       c1_0.`full_road_address_name`,
       c1_0.`road_name`,
       c1_0.`title`,
       c1_0.`content`,
       group_concat(i1_0.`image_url`),
       group_concat(v1_0.`video_url`),
       c1_0.`is_opened`,
       c1_0.`type`
from `capsule` c1_0
join `capsule_skin` c2_0 on c1_0.`capsule_skin_id` = c2_0.`capsule_skin_id` and c2_0.`deleted_at` is null
join `member` m1_0 on c1_0.`member_id` = m1_0.`member_id` and m1_0.`deleted_at` is null
join `group` g1_0 on c1_0.`group_id` = g1_0.`group_id` and g1_0.`deleted_at` is null
         left join `image` i1_0
                   on c1_0.`capsule_id` = i1_0.`capsule_id` and i1_0.`deleted_at` is null
         left join `video` v1_0 on c1_0.`capsule_id`=v1_0.`capsule_id` and v1_0.`deleted_at` is null
where (c1_0.deleted_at is null) and c1_0.`type`='GROUP' and 1=2
group by c1_0.`capsule_id`
order by c1_0.`capsule_id`
desc limit 20;

위와 같이 쿼리가 생성됨

  • mysql에서 where절이 항상 False인 경우 => Impossible Where가 실행 플랜에 나옴
  • 이는 어떤 결과도 반환하지 않음
    image

예상
Impossible Where로 결과가 없기 때문에 JOIN이나 GROUP BY가 제대로 동작하지 않은 것으로 보임

링크 (Links)

기타 사항 (Etc)

Merge 전 필요 작업 (Checklist before merge)

희망 리뷰 완료 일 (Expected due date)

@seokho-1116 seokho-1116 added the fix 버그 수정 label Aug 5, 2024
@seokho-1116 seokho-1116 self-assigned this Aug 5, 2024
@GaBaljaintheroom GaBaljaintheroom merged commit c2fa16e into develop_back_core Aug 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 버그 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants