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(desktop): allow multiple new table structure tabs

t8y28058c238b8ec
diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.ts
index 862074033e..beb41f3276 100644
--- a/apps/desktop/src/stores/queryStore.ts
+++ b/apps/desktop/src/stores/queryStore.ts
@@ -234,16 +234,18 @@ export const useQueryStore = defineStore("query", () => {
function openTableStructure(connectionId: string, database: string, schema?: string, tableName?: string) {
const resolvedTableName = tableName || "";
- const existing = tabs.value.find(
- (tab) =>
- tab.mode === "structure" &&
- tab.connectionId === connectionId &&
- tab.database === database &&
- (tab.structureTableName || "") === resolvedTableName,
- );
- if (existing) {
- activeTabId.value = existing.id;
- return existing.id;
+ if (resolvedTableName) {
+ const existing = tabs.value.find(
+ (tab) =>
+ tab.mode === "structure" &&
+ tab.connectionId === connectionId &&
+ tab.database === database &&
+ (tab.structureTableName || "") === resolvedTableName,
+ );
+ if (existing) {
+ activeTabId.value = existing.id;
+ return existing.id;
+ }
}
const title = resolvedTableName
diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts
index d9549b20a6..abd68f839c 100644
--- a/packages/app-tests/queryStore.test.ts
+++ b/packages/app-tests/queryStore.test.ts
@@ -748,3 +748,22 @@ test("tab reuse is scoped by mode and schema instead of title alone", () => {
restoreStorage();
}
});
+
+test("new table structure tabs can open multiple drafts while existing tables still reuse tabs", () => {
+ const restoreStorage = installMemoryStorage();
+ try {
+ setActivePinia(createPinia());
+ const store = useQueryStore();
+
+ const firstDraftId = store.openTableStructure("conn-1", "db", "public", "");
+ const secondDraftId = store.openTableStructure("conn-1", "db", "public", "");
+ const firstEditId = store.openTableStructure("conn-1", "db", "public", "users");
+ const secondEditId = store.openTableStructure("conn-1", "db", "public", "users");
+
+ assert.notEqual(secondDraftId, firstDraftId);
+ assert.equal(secondEditId, firstEditId);
+ assert.equal(store.tabs.length, 3);
+ } finally {
+ restoreStorage();
+ }
+});