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(sidebar): allow search to find tables hidden behind object browser

t8y239f33e15d4d8
diff --git a/src/components/sidebar/ConnectionTree.vue b/src/components/sidebar/ConnectionTree.vue
index 350f1d5399..9459a4c459 100644
--- a/src/components/sidebar/ConnectionTree.vue
+++ b/src/components/sidebar/ConnectionTree.vue
@@ -96,6 +96,12 @@ function filterTree(nodes: TreeNode[], q: string): TreeNode[] {
const filteredNodes: TreeNode[] = [];
for (const node of nodes) {
+ if (node.type === "object-browser" && node.hiddenChildren) {
+ const matches = node.hiddenChildren.filter((child) => matchSidebarLabel(normalizedLabel(child), q));
+ if (matches.length > 0) filteredNodes.push(...matches);
+ continue;
+ }
+
const label = normalizedLabel(node);
const selfMatches = !!matchSidebarLabel(label, q);
const filteredChildren = node.children ? filterTree(node.children, q) : undefined;
diff --git a/src/stores/connectionStore.ts b/src/stores/connectionStore.ts
index 54aa804e95..1256a33a16 100644
--- a/src/stores/connectionStore.ts
+++ b/src/stores/connectionStore.ts
@@ -689,17 +689,25 @@ export const useConnectionStore = defineStore("connection", () => {
[],
defaultSchemaTables.slice(0, SIDEBAR_TABLE_NODE_LIMIT),
);
- children = [
- ...previewTables,
- buildObjectBrowserNode(
- `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`,
- connectionId,
- database,
- SQLSERVER_DEFAULT_SCHEMA,
- defaultSchemaTables.length,
- ),
- ...children.filter((child) => child.type === "schema"),
- ];
+ const browserNode = buildObjectBrowserNode(
+ `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}`,
+ connectionId,
+ database,
+ SQLSERVER_DEFAULT_SCHEMA,
+ defaultSchemaTables.length,
+ );
+ const hiddenTables = defaultSchemaTables.slice(SIDEBAR_TABLE_NODE_LIMIT);
+ browserNode.hiddenChildren = hiddenTables.map((t) => ({
+ id: `${nodeId}:${SQLSERVER_DEFAULT_SCHEMA}:${t.name}`,
+ label: t.name,
+ type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table",
+ connectionId,
+ database,
+ schema: SQLSERVER_DEFAULT_SCHEMA,
+ isExpanded: false,
+ children: [],
+ }));
+ children = [...previewTables, browserNode, ...children.filter((child) => child.type === "schema")];
}
setChildren(node, children);
await savePersistedTreeChildren(cacheKey, children);
@@ -736,7 +744,19 @@ export const useConnectionStore = defineStore("connection", () => {
children: [],
}));
if (tables.length > SIDEBAR_TABLE_NODE_LIMIT) {
- children.push(buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length));
+ const hiddenTables = tables.slice(SIDEBAR_TABLE_NODE_LIMIT);
+ const browserNode = buildObjectBrowserNode(nodeId, connectionId, database, effectiveSchema, tables.length);
+ browserNode.hiddenChildren = hiddenTables.map((t) => ({
+ id: `${nodeId}:${t.name}`,
+ label: t.name,
+ type: (t.table_type === "VIEW" ? "view" : "table") as "view" | "table",
+ connectionId,
+ database,
+ schema: effectiveSchema,
+ isExpanded: false,
+ children: [],
+ }));
+ children.push(browserNode);
}
setChildren(node, children);
await savePersistedTreeChildren(cacheKey, children);
diff --git a/src/types/database.ts b/src/types/database.ts
index dca1fd7bc1..70de4478b7 100644
--- a/src/types/database.ts
+++ b/src/types/database.ts
@@ -205,6 +205,7 @@ export interface TreeNode {
schema?: string;
tableName?: string;
objectCount?: number;
+ hiddenChildren?: TreeNode[];
savedSqlId?: string;
savedSqlFolderId?: string;
meta?: ColumnInfo | IndexInfo | ForeignKeyInfo | TriggerInfo;