From 58e65608e4eb360638956e4e6cf2f70dd08f5916 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Wed, 25 Sep 2024 10:46:07 +0200 Subject: [PATCH] fixed postgres connections for readonly connection #900 --- .../dbgate-plugin-postgres/src/backend/drivers.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/dbgate-plugin-postgres/src/backend/drivers.js b/plugins/dbgate-plugin-postgres/src/backend/drivers.js index 47707a5e7..eddea38a4 100644 --- a/plugins/dbgate-plugin-postgres/src/backend/drivers.js +++ b/plugins/dbgate-plugin-postgres/src/backend/drivers.js @@ -86,14 +86,16 @@ const drivers = driverBases.map(driverBase => ({ const client = new pg.Client(options); await client.connect(); - if (isReadOnly) { - await this.query(client, 'SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY'); - } - - return { + const dbhan = { client, database, }; + + if (isReadOnly) { + await this.query(dbhan, 'SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY'); + } + + return dbhan; }, async close(dbhan) { return dbhan.client.end();