Skip to content

Commit fa759bb

Browse files
committed
fix: Don't return promises directly in exposed async functions
1 parent 687cd15 commit fa759bb

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

client.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,16 +233,16 @@ export abstract class QueryClient {
233233
this.#terminated = true;
234234
}
235235

236-
#executeQuery<T extends Array<unknown>>(
236+
async #executeQuery<T extends Array<unknown>>(
237237
_query: Query<ResultType.ARRAY>,
238238
): Promise<QueryArrayResult<T>>;
239-
#executeQuery<T>(
239+
async #executeQuery<T>(
240240
_query: Query<ResultType.OBJECT>,
241241
): Promise<QueryObjectResult<T>>;
242-
#executeQuery(
242+
async #executeQuery(
243243
query: Query<ResultType>,
244244
): Promise<QueryResult> {
245-
return this.#connection.query(query);
245+
return await this.#connection.query(query);
246246
}
247247

248248
/**
@@ -280,18 +280,18 @@ export abstract class QueryClient {
280280
* const {rows} = await my_client.queryArray<[number, string]>`SELECT ID, NAME FROM CLIENTS WHERE ID = ${id}`;
281281
* ```
282282
*/
283-
queryArray<T extends Array<unknown>>(
283+
async queryArray<T extends Array<unknown>>(
284284
query: string,
285285
args?: QueryArguments,
286286
): Promise<QueryArrayResult<T>>;
287-
queryArray<T extends Array<unknown>>(
287+
async queryArray<T extends Array<unknown>>(
288288
config: QueryOptions,
289289
): Promise<QueryArrayResult<T>>;
290-
queryArray<T extends Array<unknown>>(
290+
async queryArray<T extends Array<unknown>>(
291291
strings: TemplateStringsArray,
292292
...args: unknown[]
293293
): Promise<QueryArrayResult<T>>;
294-
queryArray<T extends Array<unknown> = Array<unknown>>(
294+
async queryArray<T extends Array<unknown> = Array<unknown>>(
295295
query_template_or_config: TemplateStringsArray | string | QueryOptions,
296296
...args: unknown[] | [QueryArguments | undefined]
297297
): Promise<QueryArrayResult<T>> {
@@ -320,7 +320,7 @@ export abstract class QueryClient {
320320
query = new Query(query_template_or_config, ResultType.ARRAY);
321321
}
322322

323-
return this.#executeQuery(query);
323+
return await this.#executeQuery(query);
324324
}
325325

326326
/**
@@ -382,18 +382,18 @@ export abstract class QueryClient {
382382
* const { rows } = await my_client.queryObject<{id: number, name: string}>`SELECT ID, NAME FROM CLIENTS WHERE ID = ${id}`;
383383
* ```
384384
*/
385-
queryObject<T>(
385+
async queryObject<T>(
386386
query: string,
387387
args?: QueryArguments,
388388
): Promise<QueryObjectResult<T>>;
389-
queryObject<T>(
389+
async queryObject<T>(
390390
config: QueryObjectOptions,
391391
): Promise<QueryObjectResult<T>>;
392-
queryObject<T>(
392+
async queryObject<T>(
393393
query: TemplateStringsArray,
394394
...args: unknown[]
395395
): Promise<QueryObjectResult<T>>;
396-
queryObject<
396+
async queryObject<
397397
T = Record<string, unknown>,
398398
>(
399399
query_template_or_config:
@@ -430,7 +430,7 @@ export abstract class QueryClient {
430430
);
431431
}
432432

433-
return this.#executeQuery<T>(query);
433+
return await this.#executeQuery<T>(query);
434434
}
435435

436436
protected resetSessionMetadata() {

0 commit comments

Comments
 (0)