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(query): keep elapsed time and stop action after no-row result

t8y2eaaf9d8f2d30
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index 595ceb48ce..8f78decef6 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -3165,7 +3165,7 @@ defineExpose({
</template>
</DataGrid>
<QueryLoadingState
- v-else-if="(!activeTab.result || isQueryExecutionErrorResult(activeTab.result)) && activeTab.isExecuting"
+ v-else-if="activeTab.isExecuting && (!activeTab.result || !hasTabularResult || isQueryExecutionErrorResult(activeTab.result))"
class="flex-1 min-h-0"
:label-key="queryExecutionLabelKey(activeTab)"
:elapsed-seconds="queryRunningElapsedSeconds"
diff --git a/apps/desktop/src/components/layout/__tests__/ContentArea.errorReExecute.spec.ts b/apps/desktop/src/components/layout/__tests__/ContentArea.errorReExecute.spec.ts
index bb0e0b6e4b..47d816b1b1 100644
--- a/apps/desktop/src/components/layout/__tests__/ContentArea.errorReExecute.spec.ts
+++ b/apps/desktop/src/components/layout/__tests__/ContentArea.errorReExecute.spec.ts
@@ -105,6 +105,12 @@ async function mountContentArea(options: { result?: QueryResult; isExecuting?: b
}
describe("ContentArea query loading state on error re-execute", () => {
+ const noRowResult: QueryResult = {
+ columns: [],
+ rows: [],
+ affected_rows: 0,
+ execution_time_ms: 1,
+ };
const errorResult: QueryResult = {
columns: ["Error"],
execution_error: true,
@@ -145,6 +151,39 @@ describe("ContentArea query loading state on error re-execute", () => {
expect(host.textContent).not.toContain("正在执行");
});
+ it("shows QueryLoadingState with elapsed time for the next query after a no-row result", async () => {
+ const startedAt = Date.now() - 1500;
+ // A statement such as `set statement_timeout to '100s'` has no columns, so
+ // the retained result cannot mount DataGrid. The next query still needs the
+ // live elapsed time and stop action while it runs (issue #13508).
+ const { host, tab } = await mountContentArea({
+ result: noRowResult,
+ isExecuting: true,
+ queryExecutionStartedAt: startedAt,
+ });
+
+ expect(host.querySelector('[data-test="data-grid"]')).toBeNull();
+ expect(host.textContent).toContain("正在执行");
+ expect(host.textContent).toMatch(/· \d+\.\d+s/);
+ expect(host.textContent).toContain("停止执行");
+
+ // Once the next query returns rows, the result grid takes over again.
+ tab.isExecuting = false;
+ tab.queryExecutionStartedAt = undefined;
+ tab.result = {
+ columns: ["pg_sleep"],
+ rows: [[""]],
+ affected_rows: 0,
+ execution_time_ms: 12,
+ client_request_wait_ms: 12,
+ };
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ await nextTick();
+
+ expect(host.querySelector('[data-test="data-grid"]')).not.toBeNull();
+ expect(host.textContent).not.toContain("正在执行");
+ });
+
it("shows DataGrid when tab has an error result and is not executing", async () => {
const { host } = await mountContentArea({
result: errorResult,