auth fix 6
This commit is contained in:
parent
7d27c9a0ff
commit
1a08f98548
@ -267,29 +267,23 @@ export class CarnetApplicationService {
|
|||||||
|
|
||||||
await client.query('BEGIN');
|
await client.query('BEGIN');
|
||||||
|
|
||||||
function escapePostgresString(str: string): string {
|
function escapePostgresCompositeField(str: string): string {
|
||||||
if (str == null) return '';
|
if (str == null) return '';
|
||||||
return `"${str.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
return str.replace(/\\/g, '\\\\').replace(/"/g, '""');
|
||||||
}
|
|
||||||
|
|
||||||
function escapePostgresValue(val: any): string {
|
|
||||||
if (val == null || val === '') return ''; // NULL or empty becomes empty string
|
|
||||||
if (typeof val === 'number') return String(val); // pass numbers as-is
|
|
||||||
return escapePostgresString(String(val)); // quote and escape strings
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const contactLiterals = body.P_GLTABLE.map(c => {
|
const contactLiterals = body.P_GLTABLE.map(c => {
|
||||||
const fields = [
|
const fields = [
|
||||||
escapePostgresValue(c.ITEMNO), // integer
|
c.ITEMNO ?? '',
|
||||||
escapePostgresValue(c.ITEMDESCRIPTION), // varchar
|
c.ITEMDESCRIPTION ?? '',
|
||||||
escapePostgresValue(c.ITEMVALUE), // numeric
|
c.ITEMVALUE ?? '',
|
||||||
escapePostgresValue(c.NOOFPIECES), // integer
|
c.NOOFPIECES ?? '',
|
||||||
escapePostgresValue(c.ITEMWEIGHT), // numeric
|
c.ITEMWEIGHT ?? '',
|
||||||
escapePostgresValue(c.ITEMWEIGHTUOM), // varchar
|
c.ITEMWEIGHTUOM ?? '',
|
||||||
escapePostgresValue(c.GOODSORIGINCOUNTRY), // varchar
|
c.GOODSORIGINCOUNTRY ?? '',
|
||||||
];
|
].map(field => escapePostgresCompositeField(String(field))).join(',');
|
||||||
|
|
||||||
return `(${fields.join(',')})`; // composite literal without outer double quotes
|
return `"(${fields})"`; // ✅ Wrap each composite in double quotes
|
||||||
});
|
});
|
||||||
|
|
||||||
const pgArrayLiteral = `{${contactLiterals.join(',')}}`;
|
const pgArrayLiteral = `{${contactLiterals.join(',')}}`;
|
||||||
@ -297,6 +291,7 @@ export class CarnetApplicationService {
|
|||||||
const callProcQuery = `
|
const callProcQuery = `
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_editgenerallistitems($1, $2::"CARNETSYS".gltable[], $3, $4)
|
CALL "CARNETSYS".carnetapplication_pkg_editgenerallistitems($1, $2::"CARNETSYS".gltable[], $3, $4)
|
||||||
`;
|
`;
|
||||||
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, pgArrayLiteral, body.P_USERID, cursorName]);
|
await client.query(callProcQuery, [body.P_HEADERID, pgArrayLiteral, body.P_USERID, cursorName]);
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user