diff --git a/frontend/lib/registry/components/modal-repeater-table/ModalRepeaterTableComponent.tsx b/frontend/lib/registry/components/modal-repeater-table/ModalRepeaterTableComponent.tsx index 64c9e95f..e16c5d72 100644 --- a/frontend/lib/registry/components/modal-repeater-table/ModalRepeaterTableComponent.tsx +++ b/frontend/lib/registry/components/modal-repeater-table/ModalRepeaterTableComponent.tsx @@ -78,7 +78,18 @@ async function fetchReferenceValue( // 연산자가 "=" 인 경우만 지원 (확장 가능) if (operator === "=") { - whereConditions[targetField] = value; + // 숫자형 ID인 경우 숫자로 변환 (문자열 '189' → 숫자 189) + // 백엔드에서 entity 타입 컬럼 검색 시 문자열이면 ILIKE 검색을 수행하므로 + // 정확한 ID 매칭을 위해 숫자로 변환해야 함 + let convertedValue = value; + if (targetField.endsWith('_id') || targetField === 'id') { + const numValue = Number(value); + if (!isNaN(numValue)) { + convertedValue = numValue; + console.log(` 🔢 ID 타입 변환: ${targetField} = "${value}" → ${numValue}`); + } + } + whereConditions[targetField] = convertedValue; } else { console.warn(`⚠️ 연산자 "${operator}"는 아직 지원되지 않습니다.`); } @@ -504,11 +515,18 @@ export function ModalRepeaterTableComponent({ const whereConditions: Record = {}; for (const cond of joinConditions) { - const value = rowData[cond.sourceField]; + let value = rowData[cond.sourceField]; if (value === undefined || value === null) { console.warn(`⚠️ 조인 조건의 소스 필드 "${cond.sourceField}" 값이 없음`); return undefined; } + // 숫자형 ID인 경우 숫자로 변환 + if (cond.targetField.endsWith('_id') || cond.targetField === 'id') { + const numValue = Number(value); + if (!isNaN(numValue)) { + value = numValue; + } + } whereConditions[cond.targetField] = value; } @@ -561,8 +579,16 @@ export function ModalRepeaterTableComponent({ } // 테이블 조회 + // 숫자형 ID인 경우 숫자로 변환 + let convertedFromValue = fromValue; + if (joinCondition.toField.endsWith('_id') || joinCondition.toField === 'id') { + const numValue = Number(fromValue); + if (!isNaN(numValue)) { + convertedFromValue = numValue; + } + } const whereConditions: Record = { - [joinCondition.toField]: fromValue + [joinCondition.toField]: convertedFromValue }; console.log(` 🔍 단계 ${i + 1}: ${tableName} 조회`, whereConditions);