fix(MySQL): not every connection gets read-only option

This commit is contained in:
Fabio Di Stasio 2022-12-23 09:24:05 +01:00
parent 2982b6cb96
commit 843c15e428
1 changed files with 3 additions and 0 deletions

View File

@ -225,6 +225,9 @@ export class MySQLClient extends AntaresCore {
if (hasAnsiQuotes)
await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
if (this._params.readonly)
await connection.query('SET SESSION TRANSACTION READ ONLY');
connection.on('connection', conn => {
if (this._params.readonly)
conn.query('SET SESSION TRANSACTION READ ONLY');