mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-21 06:00:39 +00:00
fix(sql): add databaseType parameter to findStatementAtCursor function
This commit is contained in:
@@ -173,6 +173,7 @@ async function resolveActiveExecutableSql() {
|
||||
? await resolveExecutableSqlWithBackend(tab.sql, selectedSql.value, {
|
||||
mode: settingsStore.editorSettings.executeMode,
|
||||
cursorPos: cursorPos.value,
|
||||
databaseType: activeConnection.value?.db_type,
|
||||
})
|
||||
: "";
|
||||
}
|
||||
|
||||
@@ -462,8 +462,12 @@ export async function analyzeSqlReferences(sql: string, dialect?: string): Promi
|
||||
return post("/api/query/analyze-sql-references", { sql, dialect });
|
||||
}
|
||||
|
||||
export async function findStatementAtCursor(sql: string, cursorPos: number): Promise<string> {
|
||||
return post("/api/query/find-statement-at-cursor", { sql, cursorPos });
|
||||
export async function findStatementAtCursor(
|
||||
sql: string,
|
||||
cursorPos: number,
|
||||
databaseType?: DatabaseType,
|
||||
): Promise<string> {
|
||||
return post("/api/query/find-statement-at-cursor", { sql, cursorPos, databaseType });
|
||||
}
|
||||
|
||||
export async function prepareQueryPaginationExecutionPlan(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as api from "./api";
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
|
||||
export type ExecuteMode = "all" | "current";
|
||||
|
||||
@@ -20,13 +21,13 @@ export function resolveExecutableSql(
|
||||
export async function resolveExecutableSqlWithBackend(
|
||||
fullSql: string,
|
||||
selectedSql: string,
|
||||
options?: { mode?: ExecuteMode; cursorPos?: number },
|
||||
options?: { mode?: ExecuteMode; cursorPos?: number; databaseType?: DatabaseType },
|
||||
): Promise<string> {
|
||||
const trimmedSelection = selectedSql.trim();
|
||||
if (trimmedSelection) return trimmedSelection;
|
||||
|
||||
if (options?.mode === "current" && options.cursorPos !== undefined) {
|
||||
return await api.findStatementAtCursor(fullSql, options.cursorPos);
|
||||
return await api.findStatementAtCursor(fullSql, options.cursorPos, options.databaseType);
|
||||
}
|
||||
|
||||
return fullSql;
|
||||
|
||||
@@ -416,8 +416,12 @@ export async function analyzeSqlReferences(sql: string, dialect?: string): Promi
|
||||
return invoke("analyze_sql_references", { sql, dialect });
|
||||
}
|
||||
|
||||
export async function findStatementAtCursor(sql: string, cursorPos: number): Promise<string> {
|
||||
return invoke("find_statement_at_cursor", { sql, cursorPos });
|
||||
export async function findStatementAtCursor(
|
||||
sql: string,
|
||||
cursorPos: number,
|
||||
databaseType?: DatabaseType,
|
||||
): Promise<string> {
|
||||
return invoke("find_statement_at_cursor", { sql, cursorPos, databaseType });
|
||||
}
|
||||
|
||||
export async function prepareQueryPaginationExecutionPlan(
|
||||
|
||||
@@ -19,7 +19,7 @@ test("shared API exposes backend current statement resolution", () => {
|
||||
});
|
||||
|
||||
test("execution target prefers backend current statement resolution", () => {
|
||||
assert.match(executionTargetSource, /api\.findStatementAtCursor\(fullSql, options\.cursorPos\)/);
|
||||
assert.match(executionTargetSource, /api\.findStatementAtCursor\(fullSql, options\.cursorPos, options\.databaseType\)/);
|
||||
assert.doesNotMatch(executionTargetSource, /sqlStatementSplit/);
|
||||
assert.doesNotMatch(executionTargetSource, /return findStatementAtCursor\(fullSql, options\.cursorPos\)/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user