MCPcopy Create free account
hub / github.com/github/copilot-sdk / query

Function query

nodejs/test/e2e/session_fs_sqlite.e2e.test.ts:204–246  ·  view source on GitHub ↗
(
                queryType: SessionFsSqliteQueryType,
                query: string,
                params?: Record<string, string | number | null>
            )

Source from the content-addressed store, hash-verified

202 },
203 sqlite: {
204 async query(
205 queryType: SessionFsSqliteQueryType,
206 query: string,
207 params?: Record<string, string | number | null>
208 ): Promise<SessionFsSqliteQueryResult | undefined> {
209 sqliteCalls.push({ sessionId: session.sessionId, queryType, query });
210
211 const database = getOrCreateDb();
212 const trimmed = query.trim();
213 if (trimmed.length === 0) {
214 return undefined;
215 }
216
217 switch (queryType) {
218 case "exec":
219 database.exec(trimmed);
220 return undefined;
221
222 case "query": {
223 const stmt = database.prepare(trimmed);
224 const rows = (params ? stmt.all(params) : stmt.all()) as Record<
225 string,
226 unknown
227 >[];
228 const columns = rows.length > 0 ? Object.keys(rows[0]) : [];
229 return { rows, columns, rowsAffected: 0 };
230 }
231
232 case "run": {
233 const stmt = database.prepare(trimmed);
234 const result = params ? stmt.run(params) : stmt.run();
235 return {
236 rows: [],
237 columns: [],
238 rowsAffected: Number(result.changes),
239 lastInsertRowid:
240 result.lastInsertRowid !== undefined
241 ? Number(result.lastInsertRowid)
242 : undefined,
243 };
244 }
245 }
246 },
247 async exists(): Promise<boolean> {
248 return sessionDbs.has(session.sessionId);
249 },

Callers

nothing calls this directly

Calls 4

getOrCreateDbFunction · 0.85
runMethod · 0.65
pushMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…