({
params,
getConnectionIdFromSessionIdQueryKey,
cancelQueryQueryKey,
}: {
params: CancelQueryParams;
getConnectionIdFromSessionIdQueryKey: QueryKey;
cancelQueryQueryKey: QueryKey;
})
| 34 | | { sessionId: string }; |
| 35 | |
| 36 | export async function cancelQuery({ |
| 37 | params, |
| 38 | getConnectionIdFromSessionIdQueryKey, |
| 39 | cancelQueryQueryKey, |
| 40 | }: { |
| 41 | params: CancelQueryParams; |
| 42 | getConnectionIdFromSessionIdQueryKey: QueryKey; |
| 43 | cancelQueryQueryKey: QueryKey; |
| 44 | }) { |
| 45 | let connectionId; |
| 46 | if ("sessionId" in params) { |
| 47 | const { sessionId } = params; |
| 48 | |
| 49 | const { rows } = await executeSqlV2({ |
| 50 | queries: buildGetConnectionIdFromSessionIdQuery(sessionId).compile(), |
| 51 | queryKey: getConnectionIdFromSessionIdQueryKey, |
| 52 | }); |
| 53 | |
| 54 | assertAtLeastOneRow(rows.length); |
| 55 | |
| 56 | connectionId = rows[0].connection_id; |
| 57 | } else { |
| 58 | connectionId = params.connectionId; |
| 59 | } |
| 60 | |
| 61 | const { rows } = await executeSqlV2({ |
| 62 | queries: buildCancelQuery(connectionId).compile(queryBuilder), |
| 63 | queryKey: cancelQueryQueryKey, |
| 64 | }); |
| 65 | assertAtLeastOneRow(rows.length); |
| 66 | |
| 67 | if (!rows[0].pg_cancel_backend) { |
| 68 | throw new Error("Cancel not successful"); |
| 69 | } |
| 70 | } |
no test coverage detected