Fixing issue discovered by test case.

This commit is contained in:
mike12345567 2021-09-27 13:17:31 +01:00
parent 02a3b7425e
commit ba2f6ee120
1 changed files with 7 additions and 5 deletions

View File

@ -99,6 +99,7 @@ module PostgresModule {
async function internalQuery(client: any, query: SqlQuery) { async function internalQuery(client: any, query: SqlQuery) {
// need to handle a specific issue with json data types in postgres, // need to handle a specific issue with json data types in postgres,
// new lines inside the JSON data will break it // new lines inside the JSON data will break it
if (query && query.sql) {
const matches = query.sql.match(JSON_REGEX) const matches = query.sql.match(JSON_REGEX)
if (matches && matches.length > 0) { if (matches && matches.length > 0) {
for (let match of matches) { for (let match of matches) {
@ -106,6 +107,7 @@ module PostgresModule {
query.sql = query.sql.replace(match, escaped) query.sql = query.sql.replace(match, escaped)
} }
} }
}
try { try {
return await client.query(query.sql, query.bindings || []) return await client.query(query.sql, query.bindings || [])
} catch (err) { } catch (err) {