25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(sql): preserve Oracle database link references
t8y22220eed285ca
diff --git a/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts b/apps/desktop/src/composables/__tests__/useSqlExecution.spec.tsindex 9310c37aec..74c0c6cb7e 100644--- a/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts+++ b/apps/desktop/src/composables/__tests__/useSqlExecution.spec.ts@@ -245,6 +245,31 @@ describe("useSqlExecution", () => {expect(executeCurrentSql).toHaveBeenCalledWith(resolvedSql, { openInNewResultTab: true });});+ it("executes Oracle database-link queries without opening the parameter dialog", async () => {+ const sql = "SELECT 1 FROM DUAL@WDHIS160;";+ const activeTab = ref<QueryTab | undefined>(queryTab("ORCL"));+ const activeConnection = ref<ConnectionConfig | undefined>(connection("oracle"));+ const activeOutputView = ref<"result" | "summary" | "explain" | "chart">("result");+ const queryStore = useQueryStore();+ const executeCurrentSql = vi.spyOn(queryStore, "executeCurrentSql").mockImplementation(async () => {+ if (activeTab.value) activeTab.value.result = { columns: ["1"], rows: [[1]], affected_rows: 0, execution_time_ms: 1 };+ });+ vi.spyOn(useHistoryStore(), "add").mockResolvedValue(undefined);++ const execution = useSqlExecution({+ activeTab: computed(() => activeTab.value),+ activeConnection: computed(() => activeConnection.value),+ executableSql: computed(() => sql),+ activeOutputView,+ });++ await execution.tryExecute();++ expect(execution.showSqlParameterDialog.value).toBe(false);+ expect(execution.sqlParameterNames.value).toEqual([]);+ expect(executeCurrentSql).toHaveBeenCalledWith(sql, {});+ });+it("sends native SET variables without client-side expansion", async () => {const activeTab = ref<QueryTab | undefined>(queryTab("app"));const activeConnection = ref<ConnectionConfig | undefined>(connection("mysql"));diff --git a/apps/desktop/src/lib/__tests__/sql/sqlParameters.spec.ts b/apps/desktop/src/lib/__tests__/sql/sqlParameters.spec.tsindex 136d81af5c..746c6354b4 100644--- a/apps/desktop/src/lib/__tests__/sql/sqlParameters.spec.ts+++ b/apps/desktop/src/lib/__tests__/sql/sqlParameters.spec.ts@@ -53,6 +53,14 @@ describe("extractSqlParameters", () => {expect(extractSqlParameters("select @amount/2, @total / 4")).toEqual(["amount", "total"]);});+ it("ignores Oracle database links while preserving standalone at-sign placeholders", () => {+ const sql = 'SELECT * FROM HR.EMPLOYEES@REMOTE_DB, "AUDIT_LOG"@ARCHIVE_DB WHERE tenant_id = @tenant_id';+ expect(extractSqlParameters("SELECT 1 FROM DUAL@WDHIS160;", { databaseType: "oracle" })).toEqual([]);+ expect(extractSqlParameters(sql, { databaseType: "oracle" })).toEqual(["tenant_id"]);+ expect(substituteSqlParameters(sql, { tenant_id: { kind: "number", value: "7" } }, { databaseType: "oracle" })).toBe('SELECT * FROM HR.EMPLOYEES@REMOTE_DB, "AUDIT_LOG"@ARCHIVE_DB WHERE tenant_id = 7');+ expect(extractSqlParameters("SELECT * FROM EMPLOYEES@REMOTE_DB", { databaseType: "postgres" })).toEqual(["REMOTE_DB"]);+ });+it("describes each placeholder syntax for the parameter dialog", () => {const sql = "select ? as a, :named as b, ${shell_name} as c, #{mybatis_name} as d, @sql_server_name as e";expect(extractSqlParameterDescriptors(sql)).toEqual([diff --git a/apps/desktop/src/lib/sql/sqlParameters.ts b/apps/desktop/src/lib/sql/sqlParameters.tsindex e54d8005fa..428588c6be 100644--- a/apps/desktop/src/lib/sql/sqlParameters.ts+++ b/apps/desktop/src/lib/sql/sqlParameters.ts@@ -203,7 +203,7 @@ function findSqlParameterOccurrences(sql: string, options?: SqlParameterOptions)}if (ch === "@" && isSyntaxEnabled("sqlserver")) {const name = readParameterName(sql, i + 1);- if (name && next !== "@" && sql[i - 1] !== "@" && !isJdbcxMcpScopedPackage(sql, i, i + 1 + name.length) && !nativeSqlServerParameters.declared.has(name.toLowerCase()) && !nativeSqlServerParameters.ignoredStarts.has(i)) {+ if (name && next !== "@" && sql[i - 1] !== "@" && !isOracleDatabaseLinkMarker(sql, i, options?.databaseType) && !isJdbcxMcpScopedPackage(sql, i, i + 1 + name.length) && !nativeSqlServerParameters.declared.has(name.toLowerCase()) && !nativeSqlServerParameters.ignoredStarts.has(i)) {occurrences.push({key: name,name,@@ -230,6 +230,12 @@ function findSqlParameterOccurrences(sql: string, options?: SqlParameterOptions)return occurrences;}+function isOracleDatabaseLinkMarker(sql: string, index: number, databaseType: DatabaseType | undefined): boolean {+ if (databaseType !== "oracle" || index === 0) return false;+ const previous = sql[index - 1];+ return PARAMETER_NAME_CHAR_RE.test(previous) || previous === "$" || previous === "#" || previous === '"';+}+function collectDuckDbStructFieldSeparators(sql: string): Set<number> {const separators = new Set<number>();const contexts: DuckDbStructLiteralContext[] = [];