diff options
| author | joonhoekim <26rote@gmail.com> | 2025-10-10 14:51:08 +0900 |
|---|---|---|
| committer | joonhoekim <26rote@gmail.com> | 2025-10-10 14:51:08 +0900 |
| commit | fa60be1f2ccd7cca4813092889d078cfb2ca47b9 (patch) | |
| tree | 2620f171e973c85df5a9058261cd9e49ed100c6a /lib/pos/get-dcmtm-id.ts | |
| parent | 285c71af92a191dc499c1bc3c2dfe7a964fd12c9 (diff) | |
(김준회) pos get-dcmtm-id.ts fallback 및 logging 추가
Diffstat (limited to 'lib/pos/get-dcmtm-id.ts')
| -rw-r--r-- | lib/pos/get-dcmtm-id.ts | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/lib/pos/get-dcmtm-id.ts b/lib/pos/get-dcmtm-id.ts index 353c5b1d..ae807a84 100644 --- a/lib/pos/get-dcmtm-id.ts +++ b/lib/pos/get-dcmtm-id.ts @@ -50,16 +50,30 @@ export async function getDcmtmIdByMaterialCode( debugLog(`🗄️ Oracle 쿼리 결과`, { materialCode, resultType: typeof results, hasRows: results && results[0] ? results[0].length : 0 }); // Oracle 결과 처리 (oracledb 드라이버의 결과 구조에 따라) - const rows = results[0] || results.rows || results; - debugLog(`📊 Oracle 결과 구조 분석`, { - materialCode, - resultStructure: { - hasZeroIndex: !!results[0], - hasRowsProperty: !!results.rows, - rowsType: typeof rows, - isArray: Array.isArray(rows), - rowCount: Array.isArray(rows) ? rows.length : 0 - }, + // Knex.js oracledb 클라이언트의 결과 구조: + // - 배열 형태: [rows, metaData] + // - 객체 형태: { rows: [...], metaData: [...] } + let rows; + if (Array.isArray(results)) { + // [rows, metaData] 형태 - 첫 번째 요소가 실제 데이터 + rows = results[0] || []; + } else if (results.rows) { + // { rows: [...], metaData: [...] } 형태 + rows = results.rows || []; + } else { + // 직접 배열인 경우 + rows = results || []; + } + + debugLog(`📊 Oracle 결과 구조 분석`, { + materialCode, + rawResultType: typeof results, + isRawResultArray: Array.isArray(results), + rawResultKeys: results && typeof results === 'object' ? Object.keys(results) : [], + rawResultLength: Array.isArray(results) ? results.length : (results && typeof results === 'object' ? Object.keys(results).length : 0), + extractedRowsType: typeof rows, + isExtractedRowsArray: Array.isArray(rows), + rowCount: Array.isArray(rows) ? rows.length : 0, firstRow: Array.isArray(rows) && rows.length > 0 ? rows[0] : null }); |
