Files
api_builder/backend/check_endpoints.js
GEgorov 4de1118804 modified: backend/check_endpoints.js
modified:   backend/src/services/SqlExecutor.ts
2025-11-29 16:11:42 +03:00

50 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const { Client } = require('pg');
async function testQueries() {
// Подключаемся к целевой БД (emias_pg)
const client = new Client({
host: 'm112-pgkisc-01.ncms-i.ru',
port: 5432,
database: 'kis',
user: 'XАПИД',
password: 'c4d504412b61b0560d442686dfad27'
});
await client.connect();
console.log('Connected to kis database');
const caseId = 'f580b03b-86ee-41b6-a697-1981f116c669';
// Запрос из проблемного эндпоинта (с табами)
const queryWithTabs = `SELECT\tea.c_uid a_uid,
\tp.ehr_id ehrid,
\tp.erz_number subjectid,
\tp.namespace namespace
FROM \tmm.ehr_case ec
\tINNER JOIN mm.ehr_case_action ea ON ec.last_action_id = ea.id
\tINNER JOIN mm.hospdoc hd ON hd.ehr_case_id = ec.id
\tINNER JOIN mm.mdoc md ON md.id = hd.mdoc_id
\tINNER JOIN mm.people p ON p.id = md.people_id
WHERE\tec.id = $1
AND\thd.location_status_id = 1`;
// Запрос из рабочего эндпоинта (с пробелами и CRLF)
const queryWithSpaces = `SELECT ea.c_uid a_uid,\r\n p.ehr_id ehrid,\r\n p.erz_number subjectid,\r\n p.namespace namespace\r\n FROM mm.ehr_case ec\r\n INNER JOIN mm.ehr_case_action ea ON ec.last_action_id = ea.id\r\n INNER JOIN mm.hospdoc hd ON hd.ehr_case_id = ec.id\r\n INNER JOIN mm.mdoc md ON md.id = hd.mdoc_id\r\n INNER JOIN mm.people p ON p.id = md.people_id\r\n WHERE ec.id = $1\r\n AND hd.location_status_id = 1`;
console.log('\n=== Query with TABS (problematic) ===');
console.log('HEX first 50:', Buffer.from(queryWithTabs.substring(0, 50)).toString('hex'));
const result1 = await client.query(queryWithTabs, [caseId]);
console.log('rowCount:', result1.rowCount);
console.log('rows:', JSON.stringify(result1.rows));
console.log('\n=== Query with SPACES (working) ===');
console.log('HEX first 50:', Buffer.from(queryWithSpaces.substring(0, 50)).toString('hex'));
const result2 = await client.query(queryWithSpaces, [caseId]);
console.log('rowCount:', result2.rowCount);
console.log('rows:', JSON.stringify(result2.rows));
await client.end();
}
testQueries().catch(console.error);