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): fix advanced view sidebar table search scope

zipg5846f85ce6c7
diff --git a/apps/desktop/src/components/sidebar/ConnectionTree.vue b/apps/desktop/src/components/sidebar/ConnectionTree.vue
index 0ff6964718..afc199df4e 100644
--- a/apps/desktop/src/components/sidebar/ConnectionTree.vue
+++ b/apps/desktop/src/components/sidebar/ConnectionTree.vue
@@ -33,6 +33,7 @@ const plainTreeScrollerRef = ref<HTMLElement | null>(null);
type SearchScope = "connection" | "database" | "schema" | "table" | "view";
const selectedSearchScopes = ref<SearchScope[]>([]);
const searchCollapsedIds = ref<Set<string>>(new Set());
+const searchRefreshedGroupIds = new Set<string>();
let searchTimer: number | undefined;
watch(
@@ -53,25 +54,34 @@ watch(
{ flush: "sync" },
);
-watch(deferredSearchQuery, (newQuery) => {
+watch(deferredSearchQuery, (newQuery, oldQuery) => {
store.sidebarSearchQuery = newQuery;
const tasks: Promise<void>[] = [];
for (const root of store.treeNodes) {
- findExpandedTableParents(root, tasks);
+ collectExpandedObjectGroups(root, tasks, newQuery ? searchRefreshedGroupIds : undefined);
+ }
+ if (!newQuery && oldQuery) {
+ searchRefreshedGroupIds.clear();
}
Promise.all(tasks).catch(() => {});
});
-function findExpandedTableParents(node: TreeNode, tasks: Promise<void>[]) {
- if (node.isExpanded && node.connectionId && (node.type === "database" || node.type === "schema")) {
- const groupTypes = new Set(["group-tables", "group-views", "group-procedures", "group-functions", "group-sequences", "group-packages"]);
- if (node.children?.some((child) => groupTypes.has(child.type))) {
- tasks.push(store.loadObjectGroupChildren(node, { force: true }));
+const searchableObjectGroupTypes = new Set<TreeNodeType>(["group-tables", "group-views", "group-materialized-views"]);
+
+function collectExpandedObjectGroups(node: TreeNode, tasks: Promise<void>[], refreshedGroupIds?: Set<string>) {
+ if (refreshedGroupIds && node.isExpanded && node.children) {
+ for (const child of node.children) {
+ if (child.connectionId && searchableObjectGroupTypes.has(child.type)) {
+ refreshedGroupIds.add(child.id);
+ tasks.push(store.loadObjectGroupChildren(child, { force: true }));
+ }
}
+ } else if (!refreshedGroupIds && searchRefreshedGroupIds.has(node.id)) {
+ tasks.push(store.loadObjectGroupChildren(node, { force: true }));
}
if (node.children) {
for (const child of node.children) {
- findExpandedTableParents(child, tasks);
+ collectExpandedObjectGroups(child, tasks, refreshedGroupIds);
}
}
}
diff --git a/crates/dbx-core/src/data_grid_sql.rs b/crates/dbx-core/src/data_grid_sql.rs
index 7245699aac..cfe927587b 100644
--- a/crates/dbx-core/src/data_grid_sql.rs
+++ b/crates/dbx-core/src/data_grid_sql.rs
@@ -1833,9 +1833,9 @@ mod tests {
assert_eq!(
result.statements,
vec![
- "ALTER TABLE \"people\" UPDATE \"name\" = 'Linus' WHERE \"id\" = 1;",
- "ALTER TABLE \"people\" DELETE WHERE \"id\" = 1;",
- "INSERT INTO \"people\" (\"id\", \"name\") VALUES (2, 'Grace');",
+ "ALTER TABLE `people` UPDATE `name` = 'Linus' WHERE `id` = 1;",
+ "ALTER TABLE `people` DELETE WHERE `id` = 1;",
+ "INSERT INTO `people` (`id`, `name`) VALUES (2, 'Grace');",
]
);
assert!(result.rollback_statements.is_empty());
@@ -1896,7 +1896,7 @@ mod tests {
});
assert_eq!(result.validation_error, None);
- assert_eq!(result.statements, vec!["ALTER TABLE \"events\" UPDATE \"name\" = 'Linus' WHERE \"id\" = 1;"]);
+ assert_eq!(result.statements, vec!["ALTER TABLE `events` UPDATE `name` = 'Linus' WHERE `id` = 1;"]);
}
#[test]
@@ -1946,7 +1946,7 @@ mod tests {
rows: vec![vec![json!(1), json!("Ada")]],
});
- assert_eq!(statements, vec!["ALTER TABLE \"people\" UPDATE \"name\" = 'Ada' WHERE \"id\" = 1;"]);
+ assert_eq!(statements, vec!["ALTER TABLE `people` UPDATE `name` = 'Ada' WHERE `id` = 1;"]);
}
#[test]
diff --git a/crates/dbx-core/src/db_admin_sql.rs b/crates/dbx-core/src/db_admin_sql.rs
index b6ae0401ed..1e7ea68660 100644
--- a/crates/dbx-core/src/db_admin_sql.rs
+++ b/crates/dbx-core/src/db_admin_sql.rs
@@ -562,7 +562,7 @@ mod tests {
schema: None,
table_name: "PresetSubjectInfo".to_string(),
}),
- "ALTER TABLE \"PresetSubjectInfo\" DELETE WHERE 1 = 1;"
+ "ALTER TABLE `PresetSubjectInfo` DELETE WHERE 1 = 1;"
);
assert_eq!(
build_truncate_table_sql(TableAdminSqlOptions {
@@ -570,7 +570,7 @@ mod tests {
schema: None,
table_name: "PresetSubjectInfo".to_string(),
}),
- "TRUNCATE TABLE \"PresetSubjectInfo\";"
+ "TRUNCATE TABLE `PresetSubjectInfo`;"
);
assert_eq!(
build_empty_table_sql(TableAdminSqlOptions {