fix(mongodb): guard aggregate execution paths

This commit is contained in:
徐文彬
2026-05-28 21:29:08 +08:00
parent c56bcb8e2d
commit 5ea146e08e
19 changed files with 166 additions and 26 deletions
+11 -3
View File
@@ -54,9 +54,15 @@ export function useTauriEvents(deps: {
}
}).then((unlisten) => unlistenHandles.push(unlisten));
listen<{ connection_id: string; database: string; sql: string }>("mcp-execute-query", async (event) => {
listen<{
connection_id: string;
database: string;
sql: string;
allow_writes?: boolean;
allow_dangerous?: boolean;
}>("mcp-execute-query", async (event) => {
try {
const { connection_id, database, sql } = event.payload;
const { connection_id, database, sql, allow_writes, allow_dangerous } = event.payload;
if (!connectionStore.connections.length) await connectionStore.initFromDisk();
const config = connectionStore.getConfig(connection_id);
if (!config) return;
@@ -64,7 +70,9 @@ export function useTauriEvents(deps: {
await connectionStore.ensureConnected(connection_id);
const tabId = queryStore.createTab(connection_id, database, undefined, "query");
queryStore.updateSql(tabId, sql);
await queryStore.executeTabSql(tabId, sql);
await queryStore.executeTabSql(tabId, sql, {
mongoSafety: { allowWrites: !!allow_writes, allowDangerous: !!allow_dangerous },
});
focusCurrentWindow();
} catch (e) {
console.error("[DBX] mcp-execute-query error:", e);