Skip to content

Commit 7dd4ee2

Browse files
committed
fix: setQueryTimeout for mysql2DriverDialect
1 parent 98fcda0 commit 7dd4ee2

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

common/lib/mysql_client_wrapper.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export class MySQLClientWrapper implements ClientWrapper {
4747
}
4848

4949
query(sql: any): Promise<any> {
50-
this.driverDialect.setQueryTimeout(this.properties, sql);
51-
return this.client?.query(sql);
50+
const query = { sql: sql };
51+
this.driverDialect.setQueryTimeout(this.properties, query);
52+
return this.client?.query(query);
5253
}
5354

5455
async queryWithTimeout(sql: string): Promise<any> {

mysql/lib/dialect/mysql2_driver_dialect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class MySQL2DriverDialect implements DriverDialect {
7171
setQueryTimeout(props: Map<string, any>, sql?: any, wrapperConnectTimeout?: any) {
7272
const timeout = wrapperConnectTimeout ?? props.get(WrapperProperties.WRAPPER_QUERY_TIMEOUT.name);
7373
if (timeout && !sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME]) {
74-
sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME] = timeout;
74+
sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME] = Number(timeout);
7575
}
7676
}
7777

mysql/lib/dialect/mysql_database_dialect.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,14 @@ export class MySQLDatabaseDialect implements DatabaseDialect {
118118

119119
async isClientValid(targetClient: ClientWrapper): Promise<boolean> {
120120
try {
121-
return await ClientUtils.queryWithTimeout(
122-
targetClient
123-
.query({ sql: "SELECT 1" })
124-
.then(() => {
125-
return true;
126-
})
127-
.catch(() => {
128-
return false;
129-
}),
130-
targetClient.properties
131-
);
121+
return await targetClient
122+
.query("SELECT 1")
123+
.then(() => {
124+
return true;
125+
})
126+
.catch(() => {
127+
return false;
128+
});
132129
} catch (error) {
133130
return false;
134131
}

pg/lib/dialect/node_postgres_driver_dialect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class NodePostgresDriverDialect implements DriverDialect {
7171
}
7272
}
7373

74-
setQueryTimeout(props: Map<string, any>, sql?: any, wrapperQueryTimeout?: any) {
74+
setQueryTimeout(props: Map<string, any>, wrapperQueryTimeout?: any) {
7575
const timeout = wrapperQueryTimeout ?? props.get(WrapperProperties.WRAPPER_QUERY_TIMEOUT.name);
7676
if (timeout) {
7777
props.set(NodePostgresDriverDialect.QUERY_TIMEOUT_PROPERTY_NAME, timeout);

0 commit comments

Comments
 (0)