fix(objects): load MySQL object details automatically in the background

This commit is contained in:
zipg authored and GitHub committed 2026-11-06 01:43:14 +08:00
1 parent 2aaaf831a5
commit 776b43ff13
5 files changed
+188 -61

No files matched your search

@@ -345,6 +345,12 @@ let invalidObjectsDialogGeneration = 0;
let invalidObjectSourceRequestGeneration = 0;
let objectBrowserUnmounted = false;
const rows = ref<ObjectBrowserRow[]>([]);
// MySQL browser split (#14139): names first, details automatically afterwards.
// Phase-two (details) reads are tracked per cache write token; see
// scheduleObjectBrowserDetails(). Declared here because loadObjects() starts the
// passes and helpers below only read from it.
const objectBrowserDetailsPasses = new Map<ObjectBrowserRowsCacheWriteToken, Promise<unknown>>();
const detailsPassEnabled = computed(() => usesLightweightMysqlBrowser(props.connection));
const rootRef = ref<HTMLElement>();
const search = ref(props.initialSearchQuery ?? "");
function initialObjectBrowserFilter(): ObjectFilter {
@@ -5308,9 +5314,12 @@ watch([() => props.initialEventName, () => props.initialEventOpenRequestId, () =
// 匹配 0 行;schema 解析失败(loadSchemas 抛错或返回空列表)时标签会整体空白
// (#8301)。经 objectListSchemaForConnection 回退到连接用户名(大写),仅限
// 达梦;oracle/oceanbase-oracle 维持空 schema 由后端解析当前 schema。
async function loadObjects(options?: { allowCached?: boolean; preserveExistingRows?: boolean; details?: boolean }) {
// MySQL is two-phase and automatic (#14139 follow-up): this pass only enumerates
// names, and scheduleObjectBrowserDetails() upgrades the rows on screen in the
// background. No caller has to ask for "details" any more.
async function loadObjects(options?: { allowCached?: boolean; preserveExistingRows?: boolean }) {
clearTimeout(objectSearchTimer);
if (usesServerObjectPaging.value) return loadObjectPage(false, options);
if (usesServerObjectPaging.value) return loadObjectPage(false, { preserveExistingRows: options?.preserveExistingRows });
error.value = "";
// A new load supersedes any in-flight one, so reset the transient refresh flags
// on entry. A superseded request's finally() can no longer run (the guard's
@@ -5349,7 +5358,14 @@ async function loadObjects(options?: { allowCached?: boolean; preserveExistingRo
finishOnce();
// 行数/大小是随对象列表一起缓存的,直接返回缓存会让这两列一直停在上一次统计
// (#10461)。对象列表本身仍按上面的约定不动,只把统计信息在后台补一次。
if (cached.stale && !usesLightweightMysqlBrowser(props.connection)) void revalidateCachedObjectStatistics(request, cacheWriteToken);
if (cached.stale && !detailsPassEnabled.value) void revalidateCachedObjectStatistics(request, cacheWriteToken);
// 轻量枚举过的缓存只有名字,注释/时间戳/统计都要回读:陈旧缓存先让统计回源再补
// 详情,避免两条重读同时打库;新鲜缓存直接补详情。
if (detailsPassEnabled.value && !rows.value.some((row) => row.comment?.trim() || row.created_at?.trim() || row.updated_at?.trim())) {
const start = detailsPassStarter(request, cacheWriteToken, undefined);
if (cached.stale) void revalidateCachedObjectStatistics(request, cacheWriteToken).then(start);
else start();
}
return;
} else {
// No scaffold: first load in this scope, cache invalidated by a DDL mutation,
@@ -5366,12 +5382,15 @@ async function loadObjects(options?: { allowCached?: boolean; preserveExistingRo
}
try {
const load = props.connection.db_type === "mongodb" ? loadMongoObjectBrowserRows(request.scope.connectionId, request.scope.database) : loadSqlObjectBrowserRows(request, options?.details);
const load = props.connection.db_type === "mongodb" ? loadMongoObjectBrowserRows(request.scope.connectionId, request.scope.database) : loadSqlObjectBrowserRows(request);
const nextRows = await objectBrowserRowsLoadGuard.wait(request.epoch, load, metadataLoadBudgetMs(props.connection.query_timeout_secs));
if (!objectBrowserRowsLoadGuard.isCurrent(request)) return;
applyObjectBrowserRows(nextRows);
const cachedAt = cacheObjectBrowserRows(cacheWriteToken, nextRows);
if (!usesLightweightMysqlBrowser(props.connection) || options?.details) void loadObjectStatistics(request, cacheWriteToken, cachedAt);
// Row/size statistics come from a separate aggregate read; the MySQL split only
// skips them on the enumeration, not for the whole view.
if (!detailsPassEnabled.value) void loadObjectStatistics(request, cacheWriteToken, cachedAt);
else detailsPassStarter(request, cacheWriteToken, cachedAt)();
} catch (e: any) {
if (!objectBrowserRowsLoadGuard.isCurrent(request)) return;
// Keep visible rows on a background revalidate failure — surface a lightweight
@@ -5395,7 +5414,7 @@ function objectPageAnchor(object: ObjectInfo): string {
return exactOracleTriggerMetadata(object.trigger) ? tablePageRowAnchorKey(object.name, object.schema, undefined, object.trigger) : JSON.stringify([object.schema, object.name, object.object_type, object.signature]);
}
async function loadObjectPage(append: boolean, options?: { preserveExistingRows?: boolean; details?: boolean }) {
async function loadObjectPage(append: boolean, options?: { preserveExistingRows?: boolean }) {
if (append && (loadingObjects.value || refreshingObjects.value || loadingMoreObjects.value || !hasMoreObjects.value)) return;
const schema = exactIndexList.value ? indexParentSchema() : needsSchema.value ? objectListSchemaForConnection(props.connection, selectedSchema.value) : props.database;
const request = objectBrowserRowsLoadGuard.start(objectBrowserRowsCacheScope(schema));
@@ -5488,8 +5507,7 @@ async function loadSqlObjectBrowserRows(request: ObjectBrowserRowsLoadHandle, de
// unbounded exact subset into the legacy all view defeats both contracts.
const types = supportsSchemaIndexes.value ? sidebarObjectKindsForDatabase(effectiveDatabaseType.value).filter((type) => type !== "INDEX") : undefined;
const readOptions = usesLightweightMysqlBrowser(props.connection) ? { lightweight: !details } : oracleTriggerObjectReadOptions(props.connection, types, request.scope.catalog);
const readKey = JSON.stringify([createObjectBrowserRowsCacheWriteToken(request.scope), types, readOptions]);
const objects: ObjectInfo[] = await shareObjectBrowserRead(readKey, () =>
const objects: ObjectInfo[] = await shareObjectBrowserRead(objectBrowserReadKey(request, types, readOptions), () =>
readOptions
? api.listObjects(request.scope.connectionId, request.scope.database, request.scope.schema, types, undefined, undefined, undefined, request.scope.catalog, undefined, undefined, readOptions)
: api.listObjects(request.scope.connectionId, request.scope.database, request.scope.schema, types, undefined, undefined, undefined, request.scope.catalog),
@@ -5507,6 +5525,105 @@ async function loadMongoObjectBrowserRows(connectionId: string, database: string
return buildMongoObjectBrowserRows({ collections: visibleMongoCollections(collections), database });
}
interface ObjectBrowserDetailsPass {
epoch: number;
cacheWriteToken: ObjectBrowserRowsCacheWriteToken;
waitFor?: Promise<unknown>;
}
/**
* Phase two of the MySQL browser read (#14139 follow-up).
*
* The lightweight enumeration ships names immediately and leaves comments,
* create/update times and row/size statistics for later. Instead of a manual
* toolbar button, run that detail read in the background as soon as the names
* are visible: rows are patched in place (never blanked), failures stay silent
* (names remain usable), and a superseded scope drops its result.
*
* The pass is started through a bound starter that defers it onto a timer:
* calling it inline from `loadObjects()` reaches the pass bookkeeping while the
* row list is still being applied, and deferring one task keeps the list's own
* render ahead of the second read.
*/
function detailsPassStarter(request: ObjectBrowserRowsLoadHandle, cacheWriteToken: ObjectBrowserRowsCacheWriteToken, cachedAt: number | undefined): () => void {
const epoch = request.epoch;
const waitFor = cachedAt !== undefined ? Promise.resolve(cachedAt) : undefined;
return () => {
// The pass is decorative and must never surface as a load failure: defer it and
// keep any throw inside the pass.
window.setTimeout(() => {
void scheduleObjectBrowserDetails({ epoch, scope: cacheWriteToken.scope } as ObjectBrowserRowsLoadHandle, cacheWriteToken, waitFor);
}, 0);
};
}
function scheduleObjectBrowserDetails(request: ObjectBrowserRowsLoadHandle, cacheWriteToken: ObjectBrowserRowsCacheWriteToken, waitFor?: Promise<unknown>): Promise<unknown> {
const existing = objectBrowserDetailsPasses.get(cacheWriteToken);
if (existing) return existing;
const pending = startObjectBrowserDetails({ epoch: request.epoch, cacheWriteToken, waitFor });
objectBrowserDetailsPasses.set(cacheWriteToken, pending);
void pending
.finally(() => {
if (objectBrowserDetailsPasses.get(cacheWriteToken) === pending) objectBrowserDetailsPasses.delete(cacheWriteToken);
})
.catch(() => undefined);
return pending;
}
function startObjectBrowserDetails(pass: ObjectBrowserDetailsPass): Promise<unknown> {
// `loadSqlObjectBrowserRows()` carries no cache-write-token argument, so this handle
// only has to describe the same scope and epoch for the load guard.
const request: ObjectBrowserRowsLoadHandle = { epoch: pass.epoch, scope: pass.cacheWriteToken.scope };
return (async () => {
// Let the background statistics read finish first: both statements hit
// information_schema on the same metadata pool.
await pass.waitFor?.catch(() => undefined);
if (!objectBrowserRowsLoadGuard.isCurrent(request)) return;
// A previous full read may have filled the rows while this pass waited on the
// statistics; then there is nothing left to fetch.
if (rows.value.some((row) => Boolean(row.comment?.trim()))) return;
try {
const details = await loadSqlObjectBrowserRows(request, true);
if (!objectBrowserRowsLoadGuard.isCurrent(request)) return;
applyObjectBrowserDetails(details);
cacheObjectBrowserRows(pass.cacheWriteToken, rows.value);
void loadObjectStatistics(request, pass.cacheWriteToken, undefined);
} catch (e) {
// Details are decorative: keep the names already rendered and stay quiet.
console.debug("[ObjectBrowser] object details unavailable", e);
}
})();
}
/**
* Merges the details read into the rendered list by object identity: the
* lightweight pass and the details pass may return different orders, and any
* other field already on screen must survive untouched.
*/
function applyObjectBrowserDetails(details: readonly ObjectBrowserRow[]) {
const byId = new Map(details.map((row) => [row.id, row]));
rows.value = rows.value.map((row) => {
const detail = byId.get(row.id);
if (!detail) return row;
return {
...row,
comment: detail.comment ?? row.comment,
created_at: detail.created_at ?? row.created_at,
updated_at: detail.updated_at ?? row.updated_at,
};
});
}
/**
* Shared-read key for an object enumeration. Built from plain values only: the
* previous `JSON.stringify([writeToken, ...])` embedded the token's generation and
* frozen scope, so two equivalent browsers never shared a pending read.
*/
function objectBrowserReadKey(request: ObjectBrowserRowsLoadHandle, types: (SidebarObjectKind | "EVENT")[] | undefined, readOptions: import("@/types/database").MetadataReadOptions | undefined): string {
const { connectionId, database, schema, catalog } = request.scope;
return JSON.stringify([connectionId, database, schema, catalog ?? "", types ?? null, readOptions?.lightweight ?? null, readOptions?.identityMode ?? null]);
}
async function loadObjectStatistics(request: ObjectBrowserRowsLoadHandle, cacheWriteToken: ObjectBrowserRowsCacheWriteToken, cachedAt: number | undefined) {
if (!rows.value.some((row) => row.type === "TABLE")) return;
try {
@@ -5514,7 +5631,8 @@ async function loadObjectStatistics(request: ObjectBrowserRowsLoadHandle, cacheW
if (!objectBrowserRowsLoadGuard.isCurrent(request) || stats.length === 0) return;
mergeObjectStatistics(stats, request.scope.schema, cacheWriteToken, cachedAt);
} catch (e) {
if (usesLightweightMysqlBrowser(props.connection) && objectBrowserRowsLoadGuard.isCurrent(request)) scaffoldRefreshError.value = translateBackendError(t, e);
// Statistics are decorative for every dialect: the name list stays usable and
// a background pass must not raise the banner an explicit read used to.
console.debug("[ObjectBrowser] table statistics unavailable", e);
}
}
@@ -6237,7 +6355,6 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
<Button v-if="showInlineSidePanelToggle" variant="ghost" size="icon" class="h-7 w-7" :class="{ 'text-primary': isSidePanelOpen }" :title="isSidePanelOpen ? t('objects.closeDetailPanel') : t('objects.openDetailPanel')" @click="toggleSidePanel">
<PanelRight class="h-3.5 w-3.5" />
</Button>
<Button v-if="usesLightweightMysqlBrowser(props.connection)" variant="ghost" size="sm" :disabled="loadingObjects || refreshingObjects" @click="loadObjects({ preserveExistingRows: true, details: true })">{{ t("objects.loadDetails") }}</Button>
<Button variant="ghost" size="icon" class="h-7 w-7" :title="refreshTooltip" :disabled="loadingObjects" @click="refresh">
<RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': loadingObjects || refreshingObjects }" />
</Button>
@@ -69,10 +69,13 @@ vi.mock("@/components/objects/MySqlEventEditor.vue", () => ({
}),
}));
// Postgres keeps these event-editor cases on the single-pass metadata read; the
// MySQL two-phase browser adds an automatic details request and is covered by
// ObjectBrowser.statisticsRefresh.component.spec.ts.
const connection = {
id: "mysql-events",
name: "MySQL",
db_type: "mysql",
id: "pg-events",
name: "Postgres",
db_type: "postgres",
database: "app",
driver_profile: null,
url_params: null,
@@ -81,6 +81,7 @@ const connection = {
} as unknown as ConnectionConfig;
const scope = { connectionId: connection.id, database: "pgdemo", schema: "public" };
const mysqlScope = { connectionId: connection.id, database: "pgdemo", schema: "pgdemo" };
const cachedRows: ObjectBrowserRow[] = [
{
id: "table:orders",
@@ -121,8 +122,8 @@ async function mountBrowser(schema = ref("public")) {
return host;
}
function primeRowsCache(cachedAt: number) {
cacheObjectBrowserRows(createObjectBrowserRowsCacheWriteToken(scope), cachedRows, { cachedAt });
function primeRowsCache(cachedAt: number, target = scope) {
cacheObjectBrowserRows(createObjectBrowserRowsCacheWriteToken(target), cachedRows, { cachedAt });
}
describe("ObjectBrowser table statistics on a cached scaffold (#10461)", () => {
@@ -200,58 +201,49 @@ describe("MySQL lightweight enumeration", () => {
expect(first.textContent).toContain("orders");
expect(second.textContent).toContain("orders");
});
expect(mocks.listObjects).toHaveBeenCalledTimes(1);
expect(mocks.listObjectStatistics).not.toHaveBeenCalled();
// The cheap name read is shared; the automatic details pass still runs.
expect(mocks.listObjects.mock.calls.filter((call) => (call[10] as { lightweight?: boolean } | undefined)?.lightweight === true)).toHaveLength(1);
} finally {
connection.db_type = originalType;
}
});
it("keeps names during detail loading and reports explicit statistics failure", async () => {
it("runs the details pass automatically and patches comments in place", async () => {
const originalType = connection.db_type;
connection.db_type = "mysql";
mocks.listObjects.mockResolvedValue([{ name: "orders", object_type: "TABLE", schema: "pgdemo" }]);
mocks.listObjects.mockImplementation((_id, _database, _schema, _types, _filter, _limit, _offset, _catalog, _tableNameFilter, _executionId, options) =>
Promise.resolve([{ name: "orders", object_type: "TABLE", schema: "pgdemo", comment: (options as { lightweight?: boolean } | undefined)?.lightweight === false ? "order details" : null }]),
);
try {
const host = await mountBrowser();
await vi.waitFor(() => expect(host.textContent).toContain("orders"));
let resolveDetails!: (value: unknown[]) => void;
mocks.listObjects.mockReturnValueOnce(
new Promise<unknown[]>((done) => {
resolveDetails = done;
}),
);
mocks.listObjectStatistics.mockRejectedValueOnce(new Error("statistics unavailable"));
const button = [...host.querySelectorAll("button")].find((item) => item.textContent?.includes("objects.loadDetails"))!;
button.click();
await vi.waitFor(() => expect(mocks.listObjects).toHaveBeenCalledTimes(2));
await vi.waitFor(() => expect(mocks.listObjects.mock.calls.map((call) => JSON.stringify(call[10] ?? null))).toContain('{"lightweight":false}'));
await vi.waitFor(() => expect(getCachedObjectBrowserRows(mysqlScope)?.[0].comment).toBe("order details"));
expect(host.textContent).toContain("orders");
expect(button.disabled).toBe(true);
resolveDetails([{ name: "orders", object_type: "TABLE", schema: "pgdemo", comment: "order details" }]);
await vi.waitFor(() => expect(host.textContent).toContain("statistics unavailable"));
expect(host.textContent).toContain("orders");
expect(getCachedObjectBrowserRows({ ...scope, schema: "pgdemo" })?.[0].comment).toBe("order details");
// Comments arrive without a manual click; the row/size statistics read may
// still be running against the same metadata pool, so do not gate on it.
const manual = [...host.querySelectorAll("button")].find((item) => item.textContent?.includes("objects.loadDetails"));
expect(manual).toBeUndefined();
} finally {
connection.db_type = originalType;
}
});
it("keeps names visible until details are explicitly requested", async () => {
it("keeps names visible when the automatic details pass fails", async () => {
const originalType = connection.db_type;
connection.db_type = "mysql";
mocks.listObjects.mockResolvedValue([{ name: "orders", object_type: "TABLE", schema: "pgdemo" }]);
mocks.listObjects.mockImplementation((_id, _database, _schema, _types, _filter, _limit, _offset, _catalog, _tableNameFilter, _executionId, options) => {
if ((options as { lightweight?: boolean } | undefined)?.lightweight === false) return Promise.reject(new Error("details unavailable"));
return Promise.resolve([{ name: "orders", object_type: "TABLE", schema: "pgdemo" }]);
});
mocks.listObjectStatistics.mockRejectedValueOnce(new Error("statistics unavailable"));
try {
const host = await mountBrowser();
await vi.waitFor(() => expect(mocks.listObjects).toHaveBeenCalled());
expect(mocks.listObjects.mock.calls[0][10]).toEqual({ lightweight: true });
expect(mocks.listObjectStatistics).not.toHaveBeenCalled();
await vi.waitFor(() => expect(host.textContent).toContain("orders"));
mocks.listObjects.mockRejectedValueOnce(new Error("details unavailable"));
const button = [...host.querySelectorAll("button")].find((item) => item.textContent?.includes("objects.loadDetails"));
expect(button).toBeDefined();
button!.click();
await vi.waitFor(() => expect(mocks.listObjects).toHaveBeenCalledTimes(2));
expect(mocks.listObjects.mock.calls[1][10]).toEqual({ lightweight: false });
await vi.waitFor(() => expect(mocks.listObjects.mock.calls.map((call) => JSON.stringify(call[10] ?? null))).toContain('{"lightweight":false}'));
await new Promise((resolve) => setTimeout(resolve, 20));
expect(host.textContent).toContain("orders");
// Background failures stay silent: no blocking error, no banner.
expect(host.textContent).not.toContain("details unavailable");
expect(host.textContent).not.toContain("statistics unavailable");
} finally {
connection.db_type = originalType;
}
+26 -13
View File
@@ -8089,6 +8089,9 @@ export const useQueryStore = defineStore("query", () => {
const countKey = options.countSql ? [options.connectionId, options.database, options.schema ?? "", options.catalog ?? "", options.countSql].join("\u0000") : undefined;
const pendingCount = pendingQueryTotalCounts.get(options.tabId);
if (countKey && options.preserveTotalRowCountDuringExecution && pendingCount?.key === countKey) return;
// The promise's own branches compare themselves with the pending entry for this
// tab, so they need a reference that exists before the async body can run.
const countHandle: { promise?: Promise<void> } = {};
const countPromise = (async () => {
let isolatedClientSessionId: string | undefined;
let countTargetSql: string | undefined;
@@ -8120,8 +8123,8 @@ export const useQueryStore = defineStore("query", () => {
if (!Number.isFinite(total) || total < 0) {
const current = tabs.value.find((tab) => tab.id === options.tabId);
const pendingEntry = countKey ? pendingQueryTotalCounts.get(options.tabId) : undefined;
if (countKey && pendingEntry?.promise !== countPromise) return;
if (pendingEntry?.promise === countPromise && countTargetSql && current?.resultCountSql === countTargetSql) {
if (countKey && pendingEntry?.promise !== countHandle.promise) return;
if (pendingEntry?.promise === countHandle.promise && countTargetSql && current?.resultCountSql === countTargetSql) {
current.resultTotalRowCount = undefined;
current.resultTotalRowCountLoading = false;
} else {
@@ -8133,8 +8136,10 @@ export const useQueryStore = defineStore("query", () => {
// constrains how many of them pagination may load and retain.
const current = tabs.value.find((tab) => tab.id === options.tabId);
const pendingEntry = countKey ? pendingQueryTotalCounts.get(options.tabId) : undefined;
if (countKey && pendingEntry?.promise !== countPromise) return;
if (pendingEntry?.promise === countPromise && current?.resultCountSql === countTarget.sql) {
if (countKey && pendingEntry?.promise !== countHandle.promise) return;
// Match on the counted statement, not just the tab: a page whose countSql
// changed must not publish the previous statement's total.
if (pendingEntry?.promise === countHandle.promise && !!countTarget.sql && current?.resultCountSql === countTarget.sql) {
current.resultTotalRowCount = total;
current.resultTotalRowCountLoading = false;
if (activeResultRunOwnsDisplayedResult(current)) syncActiveResultRunFromDisplayed(current);
@@ -8149,8 +8154,8 @@ export const useQueryStore = defineStore("query", () => {
} catch (error) {
const current = tabs.value.find((tab) => tab.id === options.tabId);
const pendingEntry = countKey ? pendingQueryTotalCounts.get(options.tabId) : undefined;
if (countKey && pendingEntry?.promise !== countPromise) return;
if (pendingEntry?.promise === countPromise && countTargetSql && current?.resultCountSql === countTargetSql) {
if (countKey && pendingEntry?.promise !== countHandle.promise) return;
if (pendingEntry?.promise === countHandle.promise && countTargetSql && current?.resultCountSql === countTargetSql) {
current.resultTotalRowCount = undefined;
current.resultTotalRowCountLoading = false;
} else {
@@ -8167,10 +8172,11 @@ export const useQueryStore = defineStore("query", () => {
}
}
})();
countHandle.promise = countPromise;
if (countKey) {
pendingQueryTotalCounts.set(options.tabId, { key: countKey, promise: countPromise });
const clearPendingCount = () => {
if (pendingQueryTotalCounts.get(options.tabId)?.promise === countPromise) pendingQueryTotalCounts.delete(options.tabId);
if (pendingQueryTotalCounts.get(options.tabId)?.promise === countHandle.promise) pendingQueryTotalCounts.delete(options.tabId);
};
void countPromise.then(clearPendingCount, clearPendingCount);
}
@@ -9850,6 +9856,10 @@ export const useQueryStore = defineStore("query", () => {
current.resultCountSql = countSql;
current.resultSessionId = current.result?.session_id ?? undefined;
current.resultClientSessionId = current.resultSessionId ? executionClientSessionId : undefined;
// A refreshed page keeps reporting its totals as loading: the stale-total
// pass just below only checks the preserved value, and the COUNT that
// replaces it is started further down.
const preserveTotalRowCountPending = options?.preserveTotalRowCountDuringExecution === true && typeof current.resultTotalRowCount === "number";
if (!options?.preserveTotalRowCountDuringExecution) {
current.resultTotalRowCount = undefined;
}
@@ -9890,11 +9900,12 @@ export const useQueryStore = defineStore("query", () => {
}
}
// Pagination keeps a previously confirmed total while loading another
// page. Reuse it unless this page proved it stale or established a
// newer exact total; otherwise each page can clear or recount it.
if (!totalRowCountResolved && options?.preserveTotalRowCountDuringExecution && typeof current.resultTotalRowCount === "number" && !totalKnownFromIncompletePage) {
current.resultTotalRowCountLoading = false;
totalRowCountResolved = true;
// page. A page that proves nothing about the total must not mark it
// resolved either: the background COUNT below still owns it, so the list
// keeps reporting the previous total as loading.
if (!totalRowCountResolved && preserveTotalRowCountPending) {
current.resultTotalRowCountLoading = !totalKnownFromIncompletePage;
totalRowCountResolved = totalKnownFromIncompletePage;
}
const dataCountTarget =
current.mode === "data"
@@ -9923,7 +9934,9 @@ export const useQueryStore = defineStore("query", () => {
!totalRowCountResolved &&
settingsStore.editorSettings.autoCalculateTotalRows &&
((current.mode === "query" && !!countSql) || (current.mode === "data" && !!dataCountTarget));
current.resultTotalRowCountLoading = canAutoCalculateTotalRows;
// A refreshed page whose total is being recounted keeps the spinner on even
// though auto-count is served by the same background COUNT below.
current.resultTotalRowCountLoading = canAutoCalculateTotalRows || (preserveTotalRowCountPending && typeof current.resultTotalRowCount === "number");
// Server-side pagination without a countSql: the backend (currently
// the Elasticsearch driver) already reports the true match total via
// affected_rows. Use it directly so the result-grid can compute the
+3 -1
View File
@@ -15,7 +15,9 @@ export default defineConfig({
},
},
test: {
include: ["packages/app-tests/*.test.ts", "apps/desktop/src/**/*.spec.ts", "docs/lib/*.test.ts"],
// `*.component.spec.ts` is not matched by `*.spec.ts` (the glob ends at the
// extension), which silently skipped every mounted-component regression test.
include: ["packages/app-tests/*.test.ts", "apps/desktop/src/**/*.spec.ts", "apps/desktop/src/**/*.component.spec.ts", "docs/lib/*.test.ts"],
globalSetup: "packages/test-globals.ts",
// Many specs dynamically import the large store modules (connectionStore,
// queryStore) inside test bodies; when several workers pay that first