fix(tksafety): UNION ALL collation 불일치 해결 (utf8mb4_general_ci/unicode_ci)

대시보드 UNION 쿼리에서 테이블 간 collation 불일치로 500 에러 발생.
unicode_ci 테이블 컬럼에 COLLATE utf8mb4_general_ci 명시하여 해결.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Hyungi Ahn
2026-03-13 14:58:28 +09:00
parent bf9254170b
commit 1ad82fd52c

View File

@@ -466,7 +466,7 @@ const getEntryDashboard = async (date) => {
vr.visitor_count, wc.category_name, w.workplace_name,
vr.visit_date as entry_date, vr.visit_time as entry_time,
vr.check_in_time, vr.check_out_time, vr.status,
u.name as reporter_name, vpt.purpose_name, NULL as source_note
u.name COLLATE utf8mb4_general_ci as reporter_name, vpt.purpose_name, NULL as source_note
FROM workplace_visit_requests vr
LEFT JOIN workplace_categories wc ON vr.category_id = wc.category_id
LEFT JOIN workplaces w ON vr.workplace_id = w.workplace_id
@@ -476,12 +476,12 @@ const getEntryDashboard = async (date) => {
UNION ALL
SELECT 'tbm' as source, 'internal' as request_type, NULL as visitor_company, wk.worker_name as visitor_name,
1 as visitor_count, NULL as category_name, ts.work_location as workplace_name,
SELECT 'tbm' as source, 'internal' as request_type, NULL as visitor_company, wk.worker_name COLLATE utf8mb4_general_ci as visitor_name,
1 as visitor_count, NULL as category_name, ts.work_location COLLATE utf8mb4_general_ci as workplace_name,
ts.session_date as entry_date, TIME(ts.created_at) as entry_time,
ts.created_at as check_in_time, ts.end_time as check_out_time,
CASE WHEN ta.is_present=1 THEN 'checked_in' ELSE 'absent' END as status,
leader.worker_name as reporter_name, '작업(TBM)' as purpose_name, 'TBM 세션 기준' as source_note
leader.worker_name COLLATE utf8mb4_general_ci as reporter_name, '작업(TBM)' as purpose_name, 'TBM 세션 기준' as source_note
FROM tbm_team_assignments ta
JOIN tbm_sessions ts ON ta.session_id = ts.session_id
JOIN workers wk ON ta.worker_id = wk.worker_id
@@ -491,12 +491,12 @@ const getEntryDashboard = async (date) => {
UNION ALL
SELECT 'partner' as source, 'external' as request_type,
pc.company_name as visitor_company, pwc.worker_names as visitor_name,
pwc.actual_worker_count as visitor_count, NULL as category_name, ps.workplace_name,
pc.company_name as visitor_company, pwc.worker_names COLLATE utf8mb4_general_ci as visitor_name,
pwc.actual_worker_count as visitor_count, NULL as category_name, ps.workplace_name COLLATE utf8mb4_general_ci,
DATE(pwc.check_in_time) as entry_date, TIME(pwc.check_in_time) as entry_time,
pwc.check_in_time, pwc.check_out_time,
CASE WHEN pwc.check_out_time IS NOT NULL THEN 'checked_out' ELSE 'checked_in' END as status,
u2.name as reporter_name, ps.work_description as purpose_name, NULL as source_note
u2.name COLLATE utf8mb4_general_ci as reporter_name, ps.work_description COLLATE utf8mb4_general_ci as purpose_name, NULL as source_note
FROM partner_work_checkins pwc
JOIN partner_schedules ps ON pwc.schedule_id = ps.id
JOIN partner_companies pc ON pwc.company_id = pc.id