From 7781ad69cf18aae49712f251d3e7d7d573c33224 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 25 Sep 2022 19:50:31 +0200 Subject: [PATCH] sql error line number - postgres --- plugins/dbgate-plugin-postgres/src/backend/drivers.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/dbgate-plugin-postgres/src/backend/drivers.js b/plugins/dbgate-plugin-postgres/src/backend/drivers.js index 46d11f02..4faf653a 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/drivers.js +++ b/plugins/dbgate-plugin-postgres/src/backend/drivers.js @@ -147,10 +147,14 @@ const drivers = driverBases.map(driverBase => ({ query.on('error', error => { console.log('ERROR', error); - const { message, lineNumber, procName } = error; + const { message, position, procName } = error; + let line = null; + if (position) { + line = sql.substring(0, parseInt(position)).replace(/[^\n]/g, '').length; + } options.info({ message, - line: lineNumber, + line, procedure: procName, time: new Date(), severity: 'error',