Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setQueryTimeout for mysql2DriverDialect #393

Merged
merged 4 commits into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/lib/client_wrapper.ts
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ export interface ClientWrapper {
readonly properties: Map<string, any>;
readonly id: string;

query(sql: any): Promise<any>;
query(sql: string): Promise<any>;

end(): Promise<void>;

7 changes: 4 additions & 3 deletions common/lib/mysql_client_wrapper.ts
Original file line number Diff line number Diff line change
@@ -46,9 +46,10 @@ export class MySQLClientWrapper implements ClientWrapper {
this.id = uniqueId("MySQLClient_");
}

query(sql: any): Promise<any> {
this.driverDialect.setQueryTimeout(this.properties, sql);
return this.client?.query(sql);
query(sql: string): Promise<any> {
const query = { sql: sql };
this.driverDialect.setQueryTimeout(this.properties, query);
return this.client?.query(query);
}

async queryWithTimeout(sql: string): Promise<any> {
2 changes: 1 addition & 1 deletion common/lib/pg_client_wrapper.ts
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ export class PgClientWrapper implements ClientWrapper {
this.id = uniqueId("PgClient_");
}

query(sql: any): Promise<any> {
query(sql: string): Promise<any> {
return this.client?.query(sql);
}

2 changes: 1 addition & 1 deletion common/lib/pool_client_wrapper.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ export class PoolClientWrapper implements ClientWrapper {
return this.end();
}

query(sql: any): Promise<any> {
query(sql: string): Promise<any> {
return this.client?.query(sql);
}

6 changes: 3 additions & 3 deletions mysql/lib/dialect/mysql2_driver_dialect.ts
Original file line number Diff line number Diff line change
@@ -68,10 +68,10 @@ export class MySQL2DriverDialect implements DriverDialect {
}
}

setQueryTimeout(props: Map<string, any>, sql?: any, wrapperConnectTimeout?: any) {
const timeout = wrapperConnectTimeout ?? props.get(WrapperProperties.WRAPPER_QUERY_TIMEOUT.name);
setQueryTimeout(props: Map<string, any>, sql?: any, wrapperQueryTimeout?: any) {
const timeout = wrapperQueryTimeout ?? props.get(WrapperProperties.WRAPPER_QUERY_TIMEOUT.name);
if (timeout && !sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME]) {
sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME] = timeout;
sql[MySQL2DriverDialect.QUERY_TIMEOUT_PROPERTY_NAME] = Number(timeout);
}
}

2 changes: 1 addition & 1 deletion mysql/lib/dialect/mysql_database_dialect.ts
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ export class MySQLDatabaseDialect implements DatabaseDialect {
try {
return await ClientUtils.queryWithTimeout(
targetClient
.query({ sql: "SELECT 1" })
.query("SELECT 1")
.then(() => {
return true;
})