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(search): auto-scan remaining tables on first database search

t8y2c069e3ddcde2
diff --git a/apps/desktop/src/components/search/DatabaseSearchPanel.vue b/apps/desktop/src/components/search/DatabaseSearchPanel.vue
index 084c3a1286..6f8eeb61d5 100644
--- a/apps/desktop/src/components/search/DatabaseSearchPanel.vue
+++ b/apps/desktop/src/components/search/DatabaseSearchPanel.vue
@@ -234,7 +234,14 @@ async function startSearch() {
emitState();
await loadBulkColumns(currentRun);
if (currentRun !== runId || cancelled.value) return;
- await scanTableRange(currentRun, false);
+ // 首轮默认扫完全部表:仍按 DATABASE_SEARCH_TABLE_BATCH_SIZE 分批推进,
+ // 批间让出事件循环,保证进度实时刷新且“停止”按钮可响应。
+ while (currentRun === runId && !cancelled.value && nextTableIndex.value < tableTasks.value.length) {
+ await scanTableRange(currentRun, false);
+ if (nextTableIndex.value < tableTasks.value.length) {
+ await new Promise<void>((resolve) => setTimeout(resolve, 0));
+ }
+ }
} catch (error: any) {
if (currentRun === runId && !cancelled.value) {
generalError.value = error?.message || String(error);
diff --git a/apps/desktop/src/components/search/__tests__/DatabaseSearchPanel.flow.spec.ts b/apps/desktop/src/components/search/__tests__/DatabaseSearchPanel.flow.spec.ts
index cc53ee14b9..49503e396a 100644
--- a/apps/desktop/src/components/search/__tests__/DatabaseSearchPanel.flow.spec.ts
+++ b/apps/desktop/src/components/search/__tests__/DatabaseSearchPanel.flow.spec.ts
@@ -258,4 +258,27 @@ describe("DatabaseSearchPanel scan flow", () => {
expect(api.buildDatabaseSearchSql).not.toHaveBeenCalled();
expect(states.at(-1)?.results).toHaveLength(0);
});
+
+ it("first search scans past the 200-table batch boundary without user action", async () => {
+ connectionConfig.db_type = "sqlite";
+ const tables = Array.from({ length: 205 }, (_, index) => ({ name: `T${index}`, table_type: "TABLE" }));
+ vi.mocked(api.getColumns).mockResolvedValue([] as any);
+ vi.mocked(api.buildDatabaseSearchSql).mockResolvedValue(null as any);
+
+ const { panelRef, states } = await mountPanel();
+ vi.mocked(api.listTables).mockResolvedValue(tables as any);
+ await panelRef.value.startSearch();
+ await vi.waitFor(
+ () => {
+ expect(states.at(-1)?.progressDone).toBe(205);
+ },
+ { timeout: 5000 },
+ );
+
+ // 首轮自动跨过 200 张的批边界,无需点击“继续扫描/扫描剩余”
+ expect(Math.max(...states.map((state) => state.progressDone ?? 0))).toBe(205);
+ expect(api.getColumns).toHaveBeenCalledTimes(205);
+ expect(states.at(-1)?.nextTableIndex).toBe(205);
+ expect(states.at(-1)?.progressTotal).toBe(205);
+ });
});