fix(repeat-screen-modal): 외부 테이블 조인 시 ID 타입 변환 추가

- 조인 키가 '_id' 또는 'id'인 경우 문자열을 숫자로 변환
- 백엔드 ILIKE 검색 방지로 정확한 ID 매칭 보장
- API 호출 파라미터 로깅 추가 (디버깅용)
This commit is contained in:
SeongHyun Kim 2025-12-12 13:46:20 +09:00
parent 1680163c61
commit c85841b59f
1 changed files with 18 additions and 1 deletions

View File

@ -464,8 +464,17 @@ export function RepeatScreenModalComponent({
// 조인 조건 생성
const filters: Record<string, any> = {};
for (const condition of dataSourceConfig.joinConditions) {
const refValue = representativeData[condition.referenceKey];
let refValue = representativeData[condition.referenceKey];
if (refValue !== undefined && refValue !== null) {
// 숫자형 ID인 경우 숫자로 변환 (문자열 '189' → 숫자 189)
// 백엔드에서 entity 타입 컬럼 검색 시 문자열이면 ILIKE 검색을 수행하므로
// 정확한 ID 매칭을 위해 숫자로 변환해야 함
if (condition.sourceKey.endsWith('_id') || condition.sourceKey === 'id') {
const numValue = Number(refValue);
if (!isNaN(numValue)) {
refValue = numValue;
}
}
filters[condition.sourceKey] = refValue;
}
}
@ -475,6 +484,14 @@ export function RepeatScreenModalComponent({
continue;
}
console.log(`[RepeatScreenModal] 외부 테이블 API 호출:`, {
sourceTable: dataSourceConfig.sourceTable,
filters,
joinConditions: dataSourceConfig.joinConditions,
representativeDataId: representativeData.id,
representativeDataIdType: typeof representativeData.id,
});
// API 호출 - 메인 테이블 데이터
const response = await apiClient.post(
`/table-management/tables/${dataSourceConfig.sourceTable}/data`,