diff --git a/modules/module-mysql/src/replication/MySQLConnectionManager.ts b/modules/module-mysql/src/replication/MySQLConnectionManager.ts index 3693b9ce2..7d395b1bb 100644 --- a/modules/module-mysql/src/replication/MySQLConnectionManager.ts +++ b/modules/module-mysql/src/replication/MySQLConnectionManager.ts @@ -62,7 +62,14 @@ export class MySQLConnectionManager { * @param params */ async query(query: string, params?: any[]): Promise<[RowDataPacket[], FieldPacket[]]> { - return this.promisePool.query(query, params); + let connection: mysqlPromise.PoolConnection | undefined; + try { + connection = await this.promisePool.getConnection(); + connection.query(`SET time_zone = "+00:00"`); + return connection.query(query, params); + } finally { + connection?.release(); + } } /** diff --git a/modules/module-mysql/test/src/mysql-to-sqlite.test.ts b/modules/module-mysql/test/src/mysql-to-sqlite.test.ts index 9cebdccd2..944218ea7 100644 --- a/modules/module-mysql/test/src/mysql-to-sqlite.test.ts +++ b/modules/module-mysql/test/src/mysql-to-sqlite.test.ts @@ -200,6 +200,7 @@ INSERT INTO test_data ( test('Date types mappings', async () => { await setupTable(); + // Timezone offset is set on the pool to +00:00 await connectionManager.query(` INSERT INTO test_data(date_col, datetime_col, timestamp_col, time_col, year_col) VALUES('2023-03-06', '2023-03-06 15:47', '2023-03-06 15:47', '15:47:00', '2023'); @@ -222,6 +223,7 @@ INSERT INTO test_data ( test('Date types edge cases mappings', async () => { await setupTable(); + // Timezone offset is set on the pool to +00:00 await connectionManager.query(`INSERT INTO test_data(timestamp_col) VALUES('1970-01-01 00:00:01')`); await connectionManager.query(`INSERT INTO test_data(timestamp_col) VALUES('2038-01-19 03:14:07.499')`); await connectionManager.query(`INSERT INTO test_data(datetime_col) VALUES('1000-01-01 00:00:00')`); @@ -282,8 +284,7 @@ async function getReplicatedRows(expectedTransactionsCount?: number): Promise((resolve, reject) => {