fix(editor): use editor snapshot for SQL execution

This commit is contained in:
t8y2 committed 2026-06-17 15:30:31 +08:00
1 parent 4dbd1c7cc8
commit 6e7035823a
5 files changed
+43 -18

No files matched your search

@@ -3,6 +3,18 @@ import type { DatabaseType } from "@/types/database";
export type ExecuteMode = "all" | "current";
export interface SqlExecutionSnapshot {
fullSql: string;
selectedSql: string;
cursorPos: number;
}
export type SqlExecutionOverride = string | SqlExecutionSnapshot;
export function isSqlExecutionSnapshot(value: SqlExecutionOverride | undefined): value is SqlExecutionSnapshot {
return typeof value === "object" && value !== null && typeof value.fullSql === "string" && typeof value.selectedSql === "string" && typeof value.cursorPos === "number";
}
export function resolveExecutableSql(fullSql: string, selectedSql: string, options?: { mode?: ExecuteMode; cursorPos?: number }): string {
const trimmedSelection = selectedSql.trim();
if (trimmedSelection) return trimmedSelection;