fixed postgres connections for readonly connection #900

This commit is contained in:
Jan Prochazka
2024-09-25 10:46:07 +02:00
parent 2b6fdf5a6a
commit 58e65608e4

View File

@@ -86,14 +86,16 @@ const drivers = driverBases.map(driverBase => ({
const client = new pg.Client(options); const client = new pg.Client(options);
await client.connect(); await client.connect();
if (isReadOnly) { const dbhan = {
await this.query(client, 'SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
}
return {
client, client,
database, database,
}; };
if (isReadOnly) {
await this.query(dbhan, 'SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY');
}
return dbhan;
}, },
async close(dbhan) { async close(dbhan) {
return dbhan.client.end(); return dbhan.client.end();