Skip to content

Commit 36aabf1

Browse files
authored
Merge pull request #232 from CSE-Shaco/develop
fix(core-attendance): Postgres unnest 파라미터 오류 해결 — 배열+캐스팅 적용
2 parents 42115a2 + ce65cfb commit 36aabf1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/main/java/inha/gdgoc/domain/core/attendance/repository/AttendanceRecordRepository.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ public interface AttendanceRecordRepository extends JpaRepository<AttendanceReco
2626
/* 배치 업서트(ON CONFLICT) — meeting_id 기준 */
2727
@Modifying
2828
@Query(value = """
29-
INSERT INTO public.attendance_records (meeting_id, user_id, present, updated_at)
30-
SELECT :meetingId, u, :present, NOW()
31-
FROM unnest(:userIds) AS u
32-
ON CONFLICT (meeting_id, user_id)
33-
DO UPDATE SET present = EXCLUDED.present, updated_at = NOW()
29+
INSERT INTO public.attendance_records (meeting_id, user_id, present, updated_at)
30+
SELECT :meetingId, uid, :present, NOW()
31+
FROM unnest(CAST(:userIds AS bigint[])) AS uid
32+
ON CONFLICT (meeting_id, user_id)
33+
DO UPDATE SET present = EXCLUDED.present, updated_at = NOW()
3434
""", nativeQuery = true)
35-
int upsertBatchByMeetingId(@Param("meetingId") Long meetingId, @Param("userIds") List<Long> userIds, @Param("present") boolean present);
35+
int upsertBatchByMeetingId(@Param("meetingId") Long meetingId, @Param("userIds") Long[] userIds, // 👈 배열
36+
@Param("present") boolean present);
3637
}

src/main/java/inha/gdgoc/domain/core/attendance/service/CoreAttendanceService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ public long setAttendance(String date, List<Long> userIds, boolean present) {
114114

115115
LocalDate d = LocalDate.parse(date);
116116
Long meetingId = ensureMeetingAndGetId(d);
117-
int affected = attendanceRecordRepository.upsertBatchByMeetingId(meetingId, userIds, present);
117+
118+
Long[] arr = userIds.toArray(Long[]::new); // ✅ List -> Array
119+
int affected = attendanceRecordRepository
120+
.upsertBatchByMeetingId(meetingId, arr, present);
118121
return Math.max(affected, 0);
119122
}
120123

0 commit comments

Comments
 (0)