-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-333 refactor: 이슈 수정하기 #334
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,9 +89,9 @@ Optional<ExamTicketInfoProjection> findExamTicketInfoProjectionById( | |
| FROM ExamApplicationJpaEntity ea | ||
| JOIN PaymentJpaEntity p ON p.examApplicationId = ea.id | ||
| LEFT JOIN RefundJpaEntity r ON r.examApplicationId = ea.id | ||
| WHERE p.paymentStatus = 'DONE' | ||
| AND (r IS NULL OR r.refundStatus = 'DONE') | ||
| WHERE (p.paymentStatus = 'DONE' OR r.refundStatus = 'DONE') | ||
| AND ea.applicationId IN :applicationIds | ||
| AND ea.deleted = false | ||
| """) | ||
|
Comment on lines
+92
to
95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid OR on a LEFT-joined table to prevent row multiplication; add p.deleted filter for consistency Using OR with a column from the LEFT join (Line 92) will include all rows where p.paymentStatus = 'DONE' even when there are multiple Refund rows with non-DONE statuses, multiplying results per application. It also broadens semantics to include cases where payment is not DONE but refund is DONE (intentional?), and misses the common Refactor to use EXISTS for the refund condition and restore the Apply this diff within the current query: - WHERE (p.paymentStatus = 'DONE' OR r.refundStatus = 'DONE')
- AND ea.applicationId IN :applicationIds
- AND ea.deleted = false
+ WHERE ea.applicationId IN :applicationIds
+ AND ea.deleted = false
+ AND (
+ (p.paymentStatus = 'DONE' AND p.deleted = false)
+ OR EXISTS (
+ SELECT 1 FROM RefundJpaEntity r2
+ WHERE r2.examApplicationId = ea.id
+ AND r2.refundStatus = 'DONE'
+ )
+ )Additionally, since the refund condition is evaluated via EXISTS, the LEFT JOIN to Refund is no longer needed and can be removed to simplify the query and avoid accidental fan-out: // Outside the selected lines (optional cleanup)
JOIN PaymentJpaEntity p ON p.examApplicationId = ea.id
-- remove: LEFT JOIN RefundJpaEntity r ON r.examApplicationId = ea.idIf the broadened inclusion of “refund-done even if payment not done” is intentional, the EXISTS keeps that behavior without duplicating rows. If not intentional, consider reverting to the stricter semantics. 🤖 Prompt for AI Agents |
||
| List<ExamApplicationWithStatus> findByApplicationIdIn(List<Long> applicationIds); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.