fix(editor): preserve current SQL execution boundaries
This commit is contained in:
13 files changed
+232
-44
No files matched your search
@@ -23,6 +23,7 @@ export type SqlExecutionTargetKind = "cursor" | "all";
|
||||
*/
|
||||
export interface SqlExecutionCandidate {
|
||||
kind: SqlExecutionTargetKind;
|
||||
supportedKinds: SqlExecutionTargetKind[];
|
||||
label: string;
|
||||
sql: string;
|
||||
from: number;
|
||||
@@ -40,6 +41,11 @@ export function isSqlExecutionSnapshot(value: SqlExecutionOverride | undefined):
|
||||
return typeof value === "object" && value !== null && typeof value.fullSql === "string" && typeof value.selectedSql === "string" && typeof value.cursorPos === "number" && typeof value.selectionFrom === "number" && typeof value.selectionTo === "number";
|
||||
}
|
||||
|
||||
export function executionCandidateForMode(candidates: SqlExecutionCandidate[], mode: ExecuteMode): SqlExecutionCandidate | null {
|
||||
const targetKind: SqlExecutionTargetKind = mode === "current" ? "cursor" : "all";
|
||||
return candidates.find((candidate) => candidate.supportedKinds.includes(targetKind)) ?? null;
|
||||
}
|
||||
|
||||
export function resolveExecutableSql(fullSql: string, selectedSql: string, options?: { mode?: ExecuteMode; cursorPos?: number }): string {
|
||||
const trimmedSelection = selectedSql.trim();
|
||||
if (trimmedSelection) return trimmedSelection;
|
||||
|
||||
Reference in new issue
Block a user