MCPcopy Create free account
hub / github.com/antvis/AVA / runQuery

Method runQuery

src/remote/sqlserver/engine.ts:134–157  ·  view source on GitHub ↗
(query: string, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

132 }
133
134 private async runQuery<T = Record<string, unknown>>(query: string, signal?: AbortSignal): Promise<IResult<T>> {
135 if (!this.pool) throw new Error('No data loaded. Please call source() first.');
136 throwIfAborted(signal);
137 const request = this.pool.request();
138 const cancel = () => {
139 if (this.cancelRequests.delete(cancel)) request.cancel();
140 };
141 this.cancelRequests.add(cancel);
142 let detach: (() => void) | undefined;
143 try {
144 const running = request.query<T>(query);
145 // Starting a request resets the driver's cancellation flag.
146 detach = onAbort(signal, cancel);
147 const result = await running;
148 throwIfAborted(signal);
149 return result;
150 } catch (error) {
151 throwIfAborted(signal);
152 throw error;
153 } finally {
154 detach?.();
155 this.cancelRequests.delete(cancel);
156 }
157 }
158}

Callers 2

schemaMethod · 0.95
profileMethod · 0.95

Calls 3

throwIfAbortedFunction · 0.90
onAbortFunction · 0.90
queryMethod · 0.80

Tested by

no test coverage detected