fixed readonly connection for MySQL

This commit is contained in:
Jan Prochazka
2024-09-25 10:49:37 +02:00
parent 58e65608e4
commit e3249c6d79

View File

@@ -49,13 +49,14 @@ const drivers = driverBases.map(driverBase => ({
}; };
const client = mysql2.createConnection(options); const client = mysql2.createConnection(options);
if (isReadOnly) { const dbhan = {
await this.query(client, 'SET SESSION TRANSACTION READ ONLY');
}
return {
client, client,
database, database,
}; }
if (isReadOnly) {
await this.query(dbhan, 'SET SESSION TRANSACTION READ ONLY');
}
return dbhan;
}, },
async close(dbhan) { async close(dbhan) {
return dbhan.client.close(); return dbhan.client.close();