fix(data): use saved row limit for table opens
This commit is contained in:
1 parent
21cec24e75
commit
1ff3676531
6 files changed
+19
-12
No files matched your search
@@ -1122,7 +1122,7 @@ async function openData() {
|
|||||||
|
|
||||||
const querySchema = connectionObjectTreeQuerySchema(config, node.database, tableSchema);
|
const querySchema = connectionObjectTreeQuerySchema(config, node.database, tableSchema);
|
||||||
const effectiveDbType = effectiveDatabaseTypeForConnection(config);
|
const effectiveDbType = effectiveDatabaseTypeForConnection(config);
|
||||||
const limit = tableOpenPageLimit();
|
const limit = tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
||||||
const refreshTableMetaInBackground = async () => {
|
const refreshTableMetaInBackground = async () => {
|
||||||
const metadataStartedAt = performance.now();
|
const metadataStartedAt = performance.now();
|
||||||
console.info("[DBX][openData:metadata:start]", {
|
console.info("[DBX][openData:metadata:start]", {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ async function openTableTarget(target: NavigationTarget, options: { tableInfoTab
|
|||||||
const connectionStore = useConnectionStore();
|
const connectionStore = useConnectionStore();
|
||||||
const queryStore = useQueryStore();
|
const queryStore = useQueryStore();
|
||||||
const settingsStore = useSettingsStore();
|
const settingsStore = useSettingsStore();
|
||||||
const pageLimit = tableOpenPageLimit();
|
const pageLimit = tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
||||||
|
|
||||||
connectionStore.activeConnectionId = target.connectionId;
|
connectionStore.activeConnectionId = target.connectionId;
|
||||||
const config = connectionStore.getConfig(target.connectionId);
|
const config = connectionStore.getConfig(target.connectionId);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { DEFAULT_RESULT_PAGE_SIZE, normalizeResultPageSize } from "@/lib/paginat
|
|||||||
|
|
||||||
export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;
|
export const DEFAULT_TABLE_OPEN_PAGE_LIMIT = DEFAULT_RESULT_PAGE_SIZE;
|
||||||
|
|
||||||
export function tableOpenPageLimit(): number {
|
export function tableOpenPageLimit(preferredLimit?: unknown): number {
|
||||||
// Opening a table should not inherit the mutable SQL result-grid rows-per-page setting.
|
// Data tabs should reopen with the rows-per-page preference the grid persists.
|
||||||
return normalizeResultPageSize(DEFAULT_TABLE_OPEN_PAGE_LIMIT);
|
return normalizeResultPageSize(preferredLimit, DEFAULT_TABLE_OPEN_PAGE_LIMIT);
|
||||||
}
|
}
|
||||||
@@ -2058,7 +2058,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
countSql = plan.countSql;
|
countSql = plan.countSql;
|
||||||
useAgentResultSession = plan.useAgentResultSession;
|
useAgentResultSession = plan.useAgentResultSession;
|
||||||
} else if (tab.mode === "data") {
|
} else if (tab.mode === "data") {
|
||||||
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit();
|
pageLimit = options?.pagination?.limit ?? tableOpenPageLimit(settingsStore.editorSettings.pageSize);
|
||||||
pageOffset = options?.pagination?.offset ?? 0;
|
pageOffset = options?.pagination?.offset ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2539,7 +2539,7 @@ export const useQueryStore = defineStore("query", () => {
|
|||||||
pagination:
|
pagination:
|
||||||
tab.mode === "data"
|
tab.mode === "data"
|
||||||
? {
|
? {
|
||||||
limit: tab.resultPageLimit ?? tableOpenPageLimit(),
|
limit: tab.resultPageLimit ?? tableOpenPageLimit(useSettingsStore().editorSettings.pageSize),
|
||||||
offset: tab.resultPageOffset ?? 0,
|
offset: tab.resultPageOffset ?? 0,
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@@ -1916,7 +1916,7 @@ test("data tab execution preserves pagination offset metadata", async () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("data tab default pagination is independent from query result page size", async () => {
|
test("data tab default pagination follows persisted rows-per-page", async () => {
|
||||||
const restoreStorage = installMemoryStorage();
|
const restoreStorage = installMemoryStorage();
|
||||||
setActivePinia(createPinia());
|
setActivePinia(createPinia());
|
||||||
const connectionStore = useConnectionStore();
|
const connectionStore = useConnectionStore();
|
||||||
@@ -1949,12 +1949,12 @@ test("data tab default pagination is independent from query result page size", a
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await store.executeTabSql(tabId, 'SELECT * FROM "users" LIMIT 100;');
|
await store.executeTabSql(tabId, 'SELECT * FROM "users" LIMIT 1000;');
|
||||||
|
|
||||||
assert.equal(preparedPagination, false);
|
assert.equal(preparedPagination, false);
|
||||||
assert.equal(executeBody.maxRows, 100);
|
assert.equal(executeBody.maxRows, 1000);
|
||||||
assert.equal(executeBody.fetchSize, 100);
|
assert.equal(executeBody.fetchSize, 1000);
|
||||||
assert.equal(tab.resultPageLimit, 100);
|
assert.equal(tab.resultPageLimit, 1000);
|
||||||
assert.equal(tab.resultPageOffset, 0);
|
assert.equal(tab.resultPageOffset, 0);
|
||||||
} finally {
|
} finally {
|
||||||
globalThis.fetch = originalFetch;
|
globalThis.fetch = originalFetch;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { createPinia, setActivePinia } from "pinia";
|
|||||||
import { DEFAULT_SQL_FORMATTER_SETTINGS } from "../../apps/desktop/src/lib/sqlFormatterConfig.ts";
|
import { DEFAULT_SQL_FORMATTER_SETTINGS } from "../../apps/desktop/src/lib/sqlFormatterConfig.ts";
|
||||||
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS } from "../../apps/desktop/src/lib/tableColumnTemplates.ts";
|
import { DEFAULT_TABLE_COLUMN_TEMPLATE_FIELDS } from "../../apps/desktop/src/lib/tableColumnTemplates.ts";
|
||||||
import { DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY } from "../../apps/desktop/src/lib/appFonts.ts";
|
import { DEFAULT_UI_FONT_FAMILY, SYSTEM_UI_FONT_FAMILY } from "../../apps/desktop/src/lib/appFonts.ts";
|
||||||
|
import { tableOpenPageLimit } from "../../apps/desktop/src/lib/tableOpenPageLimit.ts";
|
||||||
import { AI_PROVIDER_PRESETS, DEFAULT_EDITOR_SETTINGS, normalizeAiConfig, normalizeEditorSettings, useSettingsStore } from "../../apps/desktop/src/stores/settingsStore.ts";
|
import { AI_PROVIDER_PRESETS, DEFAULT_EDITOR_SETTINGS, normalizeAiConfig, normalizeEditorSettings, useSettingsStore } from "../../apps/desktop/src/stores/settingsStore.ts";
|
||||||
|
|
||||||
const OLD_FONT_SIZE_KEY = "dbx-query-editor-font-size";
|
const OLD_FONT_SIZE_KEY = "dbx-query-editor-font-size";
|
||||||
@@ -47,6 +48,12 @@ test("normalizes saved query result page size", () => {
|
|||||||
assert.equal(normalizeEditorSettings({ pageSize: 0 }).pageSize, 100);
|
assert.equal(normalizeEditorSettings({ pageSize: 0 }).pageSize, 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("uses saved rows-per-page for table opens", () => {
|
||||||
|
assert.equal(tableOpenPageLimit(), 100);
|
||||||
|
assert.equal(tableOpenPageLimit(500), 500);
|
||||||
|
assert.equal(tableOpenPageLimit(0), 100);
|
||||||
|
});
|
||||||
|
|
||||||
test("defaults export batch size to 2000 rows", () => {
|
test("defaults export batch size to 2000 rows", () => {
|
||||||
assert.equal(DEFAULT_EDITOR_SETTINGS.exportBatchSize, 2000);
|
assert.equal(DEFAULT_EDITOR_SETTINGS.exportBatchSize, 2000);
|
||||||
assert.equal(normalizeEditorSettings({}).exportBatchSize, 2000);
|
assert.equal(normalizeEditorSettings({}).exportBatchSize, 2000);
|
||||||
|
|||||||
Reference in new issue
Block a user