fix(hana): improve metadata fallback and SQLScript parameters

This commit is contained in:
LRcoding authored and GitHub committed 2026-07-08 17:25:34 +08:00
1 parent fd80464cb2
commit 430f097602
6 files changed
+57 -22

No files matched your search

@@ -1,4 +1,4 @@
import { ref, type Ref, type ComputedRef } from "vue";
import { ref, watch, type Ref, type ComputedRef } from "vue";
import { useI18n } from "vue-i18n";
import { useQueryStore } from "@/stores/queryStore";
import { useHistoryStore } from "@/stores/historyStore";
@@ -12,7 +12,7 @@ import { sqlMetadataRefreshTarget } from "@/lib/sql/sqlMetadataRefresh";
import { classifyRedisCommandSafety, firstRedisCommandToken } from "@/lib/redis/redisCommandSafety";
import { isSqlExecutionSnapshot, resolveExecutableSql, type SqlExecutionOverride, type SqlExecutionSnapshot } from "@/lib/sql/sqlExecutionTarget";
import { extractSqlParameterDescriptors, type SqlParameterDescriptor } from "@/lib/sql/sqlParameters";
import type { ConnectionConfig, QueryTab } from "@/types/database";
import type { ConnectionConfig, DatabaseType, QueryTab } from "@/types/database";
const DANGER_RE = /^\s*(DROP|DELETE|TRUNCATE|ALTER|UPDATE|MERGE|REPLACE)\b/i;
@@ -61,6 +61,7 @@ export function useSqlExecution(deps: {
const showSqlParameterDialog = ref(false);
const sqlParameterSourceSql = ref("");
const sqlParameterNames = ref<SqlParameterDescriptor[]>([]);
const sqlParameterDatabaseType = ref<DatabaseType | undefined>();
async function resolvedExecutableSql(source?: SqlExecutionOverride): Promise<string> {
if (typeof source === "string") return source;
@@ -107,10 +108,12 @@ export function useSqlExecution(deps: {
}
function prepareSqlParameterDialog(sql: string): boolean {
const parameters = extractSqlParameterDescriptors(sql);
const databaseType = deps.activeConnection.value?.db_type;
const parameters = extractSqlParameterDescriptors(sql, { databaseType });
if (!parameters.length) return false;
sqlParameterSourceSql.value = sql;
sqlParameterNames.value = parameters;
sqlParameterDatabaseType.value = databaseType;
showSqlParameterDialog.value = true;
return true;
}
@@ -201,9 +204,17 @@ export function useSqlExecution(deps: {
showSqlParameterDialog.value = false;
sqlParameterSourceSql.value = "";
sqlParameterNames.value = [];
sqlParameterDatabaseType.value = undefined;
await continueExecute(sql);
}
watch(showSqlParameterDialog, (open) => {
if (open) return;
sqlParameterSourceSql.value = "";
sqlParameterNames.value = [];
sqlParameterDatabaseType.value = undefined;
});
return {
dangerSql,
pendingDangerSql,
@@ -217,6 +228,7 @@ export function useSqlExecution(deps: {
showSqlParameterDialog,
sqlParameterSourceSql,
sqlParameterNames,
sqlParameterDatabaseType,
onSqlParametersConfirm,
explainMode,
};