From 1ad82fd52c7557b40a2792517479c1e511c019c3 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 13 Mar 2026 14:58:28 +0900 Subject: [PATCH] =?UTF-8?q?fix(tksafety):=20UNION=20ALL=20collation=20?= =?UTF-8?q?=EB=B6=88=EC=9D=BC=EC=B9=98=20=ED=95=B4=EA=B2=B0=20(utf8mb4=5Fg?= =?UTF-8?q?eneral=5Fci/unicode=5Fci)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 대시보드 UNION 쿼리에서 테이블 간 collation 불일치로 500 에러 발생. unicode_ci 테이블 컬럼에 COLLATE utf8mb4_general_ci 명시하여 해결. Co-Authored-By: Claude Opus 4.6 --- tksafety/api/models/visitRequestModel.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tksafety/api/models/visitRequestModel.js b/tksafety/api/models/visitRequestModel.js index 42a6404..6a1b649 100644 --- a/tksafety/api/models/visitRequestModel.js +++ b/tksafety/api/models/visitRequestModel.js @@ -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