mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
fix(PostgreSQL): wrong export formato of JSON fields
This commit is contained in:
@ -40,7 +40,7 @@ export const objectToGeoJSON = (val: any) => {
|
|||||||
export const escapeAndQuote = (val: string, client: ClientCode) => {
|
export const escapeAndQuote = (val: string, client: ClientCode) => {
|
||||||
const { stringsWrapper: sw } = customizations[client];
|
const { stringsWrapper: sw } = customizations[client];
|
||||||
// eslint-disable-next-line no-control-regex
|
// eslint-disable-next-line no-control-regex
|
||||||
const CHARS_TO_ESCAPE = /[\0\b\t\n\r\x1a"'\\]/g;
|
const CHARS_TO_ESCAPE = sw === '"' ? /[\0\b\t\n\r\x1a"'\\]/g : /[\0\b\t\n\r\x1a'\\]/g;
|
||||||
const CHARS_ESCAPE_MAP: Record<string, string> = {
|
const CHARS_ESCAPE_MAP: Record<string, string> = {
|
||||||
'\0': '\\0',
|
'\0': '\\0',
|
||||||
'\b': '\\b',
|
'\b': '\\b',
|
||||||
@ -48,10 +48,13 @@ export const escapeAndQuote = (val: string, client: ClientCode) => {
|
|||||||
'\n': '\\n',
|
'\n': '\\n',
|
||||||
'\r': '\\r',
|
'\r': '\\r',
|
||||||
'\x1a': '\\Z',
|
'\x1a': '\\Z',
|
||||||
'"': '\\"',
|
|
||||||
'\'': '\\\'',
|
'\'': '\\\'',
|
||||||
'\\': '\\\\'
|
'\\': '\\\\'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (sw === '"')
|
||||||
|
CHARS_ESCAPE_MAP['"'] = '\\"';
|
||||||
|
|
||||||
let chunkIndex = CHARS_TO_ESCAPE.lastIndex = 0;
|
let chunkIndex = CHARS_TO_ESCAPE.lastIndex = 0;
|
||||||
let escapedVal = '';
|
let escapedVal = '';
|
||||||
let match;
|
let match;
|
||||||
@ -97,10 +100,19 @@ export const valueToSqlString = (args: {
|
|||||||
}
|
}
|
||||||
else if ('isArray' in field && field.isArray) {
|
else if ('isArray' in field && field.isArray) {
|
||||||
let localVal;
|
let localVal;
|
||||||
if (Array.isArray(val))
|
if (Array.isArray(val)) {
|
||||||
localVal = JSON.stringify(val).replaceAll('[', '{').replaceAll(']', '}');
|
localVal = JSON
|
||||||
else
|
.stringify(val)
|
||||||
localVal = typeof val === 'string' ? val.replaceAll('[', '{').replaceAll(']', '}') : '';
|
.replaceAll('[', '{')
|
||||||
|
.replaceAll(']', '}');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localVal = typeof val === 'string'
|
||||||
|
? val
|
||||||
|
.replaceAll('[', '{')
|
||||||
|
.replaceAll(']', '}')
|
||||||
|
: '';
|
||||||
|
}
|
||||||
parsedValue = `'${localVal}'`;
|
parsedValue = `'${localVal}'`;
|
||||||
}
|
}
|
||||||
else if (TEXT_SEARCH.includes(field.type))
|
else if (TEXT_SEARCH.includes(field.type))
|
||||||
|
Reference in New Issue
Block a user