Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(objects): prevent idle object browser refresh

zipgf184bc3055a9
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index 7936f80cb6..4643204f61 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -2202,7 +2202,7 @@ onBeforeUnmount(() => {
});
watch(
- () => [props.connection.id, props.database, props.schema] as const,
+ [() => props.connection.id, () => props.database, () => props.schema],
async () => {
selectedSchema.value = props.schema;
userHasSelectedFilter.value = false;
diff --git a/apps/desktop/src/lib/__tests__/table/objectBrowserContextWatch.spec.ts b/apps/desktop/src/lib/__tests__/table/objectBrowserContextWatch.spec.ts
new file mode 100644
index 0000000000..1f37455cc4
--- /dev/null
+++ b/apps/desktop/src/lib/__tests__/table/objectBrowserContextWatch.spec.ts
@@ -0,0 +1,29 @@
+import { readFileSync } from "node:fs";
+import { nextTick, ref, watch } from "vue";
+import { describe, expect, it } from "vitest";
+
+const objectBrowserSource = readFileSync(new URL("../../../components/objects/ObjectBrowser.vue", import.meta.url), "utf8");
+
+describe("ObjectBrowser context watcher", () => {
+ it("watches context fields independently", () => {
+ expect(objectBrowserSource).toContain("[() => props.connection.id, () => props.database, () => props.schema]");
+ expect(objectBrowserSource).not.toContain("() => [props.connection.id, props.database, props.schema]");
+ });
+
+ it("ignores connection object replacement when the context values stay unchanged", async () => {
+ const connection = ref({ id: "connection-1" });
+ const database = ref("database-1");
+ const schema = ref<string | undefined>("public");
+ let reloads = 0;
+ const stop = watch([() => connection.value.id, () => database.value, () => schema.value], () => reloads++);
+
+ connection.value = { id: "connection-1" };
+ await nextTick();
+ expect(reloads).toBe(0);
+
+ schema.value = "audit";
+ await nextTick();
+ expect(reloads).toBe(1);
+ stop();
+ });
+});