fix: show schemas directly under connection for DM8 and Oracle (#259)

Single-database types (DM8, Oracle) now use list_schemas instead of
list_databases when expanding a connection, matching Navicat/DataGrip
behavior and returning the complete schema list.
This commit is contained in:
t8y2 2026-05-14 23:32:43 +08:00
parent 164fd7fb82
commit 218042cfd2
1 changed files with 26 additions and 6 deletions

View File

@ -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;