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: show schemas directly under connection for DM8 and Oracle (#259)

t8y2218042cfd26a
diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts
index f5185dbe6f..fdbdf4d1ea 100644
--- a/src/stores/connectionStore.ts
+++ b/src/stores/connectionStore.ts
@@ -565,13 +565,33 @@ export const useConnectionStore = defineStore("connection", () => {
try {
await ensureConnected(connectionId);
if (useCachedChildren(node, options)) return;
- const cacheKey = schemaCacheKey(connectionId, "databases");
- if (!options?.force && (await loadPersistedTreeChildren(node, cacheKey))) return;
- const databases = await api.listDatabases(connectionId);
- const children = withSavedSqlRoot(connectionId, buildDatabaseTreeNodes(connectionId, databases), node);
- setChildren(node, children);
- await savePersistedTreeChildren(cacheKey, children);
+ const config = getConfig(connectionId);
+ if (config?.db_type === "dameng" || config?.db_type === "oracle") {
+ const effectiveDb = config.database || "";
+ const cacheKey = schemaCacheKey(connectionId, effectiveDb, "schemas");
+ if (!options?.force && (await loadPersistedTreeChildren(node, cacheKey))) return;
+ const schemas = await api.listSchemas(connectionId, effectiveDb);
+ const schemaNodes: TreeNode[] = schemas.map((s) => ({
+ id: `${connectionId}:${s}:${s}`,
+ label: s,
+ type: "schema" as const,
+ connectionId,
+ database: s,
+ schema: s,
+ isExpanded: false,
+ children: [],
+ }));
+ setChildren(node, withSavedSqlRoot(connectionId, schemaNodes, node));
+ await savePersistedTreeChildren(cacheKey, schemaNodes);
+ } else {
+ const cacheKey = schemaCacheKey(connectionId, "databases");
+ if (!options?.force && (await loadPersistedTreeChildren(node, cacheKey))) return;
+ const databases = await api.listDatabases(connectionId);
+ const children = withSavedSqlRoot(connectionId, buildDatabaseTreeNodes(connectionId, databases), node);
+ setChildren(node, children);
+ await savePersistedTreeChildren(cacheKey, children);
+ }
node.isExpanded = true;
} finally {
node.isLoading = false;