fix(grid): preserve exact totals beyond the result row limit

Closes #6786
This commit is contained in:
t8y2 committed 2026-08-20 14:26:52 +00:00
1 parent b4015a4393
commit 69e5e81071
5 files changed
+61 -15

No files matched your search

@@ -205,7 +205,7 @@ import {
replaceColumnValueFilterCondition,
} from "@/lib/dataGrid/dataGridColumnFilter";
import { normalizeResultPageSize, resultPageSizeMenuOptions } from "@/lib/dataGrid/paginationPageSize";
import { continuousQueryResultMaxRows } from "@/lib/dataGrid/queryResultRowLimit";
import { continuousQueryResultMaxRows, effectiveQueryResultMaxRows } from "@/lib/dataGrid/queryResultRowLimit";
import { allNullColumnIndexes } from "@/lib/dataGrid/dataGridColumnVisibility";
import { buildDataGridColumnLookupItems, dataGridColumnCommentFor, filterDataGridColumnLookupItems } from "@/lib/dataGrid/dataGridColumnLookup";
import { uniqueDataGridColumnOrderKeys } from "@/lib/dataGrid/dataGridColumnOrder";
@@ -633,6 +633,8 @@ const dataGridRenderMode = computed(() => settingsStore.editorSettings.dataGridR
const dataGridSearchMode = computed(() => settingsStore.editorSettings.dataGridSearchMode);
const compactDataGridToolbar = computed(() => isDataGridToolbarCompact(dataGridTopbarWidth.value, dataGridViewportWidth.value, DATA_GRID_CONDITION_TOOLBAR_MIN_WIDTH));
const infiniteScrollEnabled = computed(() => props.paginationEnabled && settingsStore.editorSettings.infiniteScroll);
const queryResultMaxRows = computed(() => effectiveQueryResultMaxRows(settingsStore.editorSettings.queryResultMaxRowsEnabled, settingsStore.editorSettings.queryResultMaxRows));
const paginationMaxRows = computed(() => (isResultsContext.value ? queryResultMaxRows.value : undefined));
const infiniteScrollMaxRows = computed(() => continuousQueryResultMaxRows(settingsStore.editorSettings.queryResultMaxRowsEnabled, settingsStore.editorSettings.queryResultMaxRows));
const flatteningMultiLineEnabled = computed(() => settingsStore.editorSettings.flatteningMultiLineText);
const expandedCellEditor = ref<{ rowId: number; col: number } | null>(null);
@@ -3058,6 +3060,7 @@ const paginationTotalRowCount = computed(() =>
paginationTotalRowCount: props.paginationTotalRowCount,
serverKnownTotalRowCount: serverKnownTotalRowCount.value,
totalRowCountIsExact: totalRowCountIsExact.value,
maxRows: paginationMaxRows.value,
}),
);
// Only a server-confirmed total drives pagination — an inferred total means
@@ -3335,8 +3338,9 @@ function applyCustomPageSize() {
}
function jumpToCountedLastPage(total: number) {
if (total <= 0) return;
const lastPageNum = Math.max(1, Math.ceil(total / pageSize.value));
const paginationTotal = resolveDataGridPaginationTotal({ paginationTotalRowCount: total, totalRowCountIsExact: true, maxRows: paginationMaxRows.value });
if (paginationTotal === undefined || paginationTotal <= 0) return;
const lastPageNum = Math.max(1, Math.ceil(paginationTotal / pageSize.value));
if (lastPageNum <= currentPage.value) return;
// Do not bump currentPage before the new page loads — otherwise stale rows
// briefly render with last-page indexes (e.g. 12001-13000) and flash a fake full page.
@@ -42,9 +42,10 @@ export function dataGridTotalRowCountLabelKey(totalRowCountIsExact: boolean, ine
return inexactMode === "estimated" ? "grid.totalRowCountEstimated" : "grid.totalRowCountAtLeast";
}
export function resolveDataGridPaginationTotal(options: { paginationTotalRowCount?: number; serverKnownTotalRowCount?: number; totalRowCountIsExact: boolean }): number | undefined {
if (options.paginationTotalRowCount !== undefined) return options.paginationTotalRowCount;
return options.totalRowCountIsExact ? options.serverKnownTotalRowCount : undefined;
export function resolveDataGridPaginationTotal(options: { paginationTotalRowCount?: number; serverKnownTotalRowCount?: number; totalRowCountIsExact: boolean; maxRows?: number }): number | undefined {
const total = options.paginationTotalRowCount ?? (options.totalRowCountIsExact ? options.serverKnownTotalRowCount : undefined);
if (total === undefined || options.maxRows === undefined) return total;
return Math.min(total, options.maxRows);
}
export function hasCompleteLocalDataGridResult(options: CompleteLocalDataGridResultOptions): boolean {
+4 -5
View File
@@ -4115,7 +4115,6 @@ export const useQueryStore = defineStore("query", () => {
traceId: string;
elapsed: () => string;
timeoutSecs: number;
maxRows?: number;
}) {
const resultRowCount = options.result.rows.length;
if (resultRowCount <= 0) {
@@ -4158,11 +4157,12 @@ export const useQueryStore = defineStore("query", () => {
setQueryTotalRowCountIfCurrent(options.tabId, options.executionId, options.result, undefined);
return;
}
const cappedTotal = capQueryResultTotal(total, options.maxRows);
setQueryTotalRowCountIfCurrent(options.tabId, options.executionId, options.result, cappedTotal);
// COUNT describes all matching rows; the configured result limit only
// constrains how many of them pagination may load and retain.
setQueryTotalRowCountIfCurrent(options.tabId, options.executionId, options.result, total);
queryExecutionLog("info", "count:done", {
traceId: options.traceId,
total: cappedTotal,
total,
elapsed: options.elapsed(),
});
} catch (error) {
@@ -5151,7 +5151,6 @@ export const useQueryStore = defineStore("query", () => {
traceId,
elapsed,
timeoutSecs: queryTimeoutSecs,
maxRows: queryResultMaxRows,
});
}
queryExecutionLog("info", "result:assigned", {