fix(mongodb): honor current command execution mode (#2702)
This commit is contained in:
1 parent
18e5df6f5e
commit
d7e2eac307
3 files changed
+55
-7
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import * as api from "@/lib/backend/api";
|
||||
import { mongoCommandRangeAtCursor } from "@/lib/sql/sqlStatementRanges";
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
|
||||
export type ExecuteMode = "all" | "current";
|
||||
@@ -52,10 +53,12 @@ export async function resolveExecutableSqlWithBackend(fullSql: string, selectedS
|
||||
const trimmedSelection = selectedSql.trim();
|
||||
if (trimmedSelection) return trimmedSelection;
|
||||
|
||||
// MongoDB uses dedicated per-command gutter actions for "current command";
|
||||
// the main editor execute action keeps its long-standing "run all text"
|
||||
// behavior when nothing is selected.
|
||||
if (options?.databaseType === "mongodb") return fullSql;
|
||||
if (options?.databaseType === "mongodb") {
|
||||
if (options.mode === "current" && options.cursorPos !== undefined) {
|
||||
return mongoCommandRangeAtCursor(fullSql, options.cursorPos)?.sql ?? fullSql;
|
||||
}
|
||||
return fullSql;
|
||||
}
|
||||
|
||||
if (options?.mode === "current" && options.cursorPos !== undefined) {
|
||||
return await api.findStatementAtCursor(fullSql, options.cursorPos, options.databaseType);
|
||||
|
||||
Reference in new issue
Block a user