feat(settings): configurable query result max rows with unified load limit

This commit is contained in:
zipg authored and GitHub committed 2026-08-11 13:07:35 +08:00
1 parent 89d65e96ed
commit 0c407c2d03
26 files changed
+446 -187

No files matched your search

@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { EDITOR_SETTINGS_DRAFT_KEYS, editorSettingsDraftFromSettings, editorSettingsDraftChanged, editorSettingsPatchFromDraft, normalizeTableOpenPageSizeDraft } from "../editorSettingsDraft";
import { EDITOR_SETTINGS_DRAFT_KEYS, editorSettingsDraftFromSettings, editorSettingsDraftChanged, editorSettingsPatchFromDraft, normalizeQueryResultMaxRowsDraft, normalizeTableOpenPageSizeDraft } from "../editorSettingsDraft";
import type { EditorSettings } from "@/stores/settingsStore";
function makeSettings(overrides: Partial<EditorSettings> = {}): EditorSettings {
@@ -7,6 +7,8 @@ function makeSettings(overrides: Partial<EditorSettings> = {}): EditorSettings {
autoCalculateTotalRows: false,
pageSize: 100,
tableOpenPageSize: 100,
queryResultMaxRowsEnabled: true,
queryResultMaxRows: 100000,
sqlEngine: "desktop",
tabSize: 2,
keywordCase: "upper",
@@ -35,7 +37,10 @@ describe("EDITOR_SETTINGS_DRAFT_KEYS", () => {
});
it("includes the table-open page size", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("pageSize");
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("tableOpenPageSize");
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("queryResultMaxRowsEnabled");
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("queryResultMaxRows");
});
it("includes the saved SQL open target mode", () => {
@@ -89,7 +94,8 @@ describe("editorSettingsDraftFromSettings", () => {
describe("normalizeTableOpenPageSizeDraft", () => {
it.each([
[200000, 100000],
[200000, 200000],
[2000000, 1000000],
[0, 100],
[-1, 100],
["123.9", 123],
@@ -102,6 +108,17 @@ describe("normalizeTableOpenPageSizeDraft", () => {
});
});
describe("normalizeQueryResultMaxRowsDraft", () => {
it.each([
[250000, 250000],
[0, 1],
[2147483648, 2147483647],
[Number.NaN, 100000],
])("normalizes %s to %s", (value, expected) => {
expect(normalizeQueryResultMaxRowsDraft(value)).toBe(expected);
});
});
describe("editorSettingsDraftChanged", () => {
it("detects change in continueOnErrorOnBatch", () => {
const settings = makeSettings({ continueOnErrorOnBatch: false });
@@ -181,7 +198,7 @@ describe("editorSettingsPatchFromDraft", () => {
const draft = editorSettingsDraftFromSettings(settings);
const base = editorSettingsDraftFromSettings(settings);
draft.tableOpenPageSize = 200000.9;
expect(editorSettingsPatchFromDraft(draft, base).tableOpenPageSize).toBe(100000);
expect(editorSettingsPatchFromDraft(draft, base).tableOpenPageSize).toBe(200000);
});
it("includes the saved SQL open target when changed", () => {
@@ -131,7 +131,7 @@ describe("settings search", () => {
{ titleKey: "settings.savedSqlOpenTarget", category: "editor", targetId: "editor" },
{ titleKey: "settings.confirmDangerousSqlExecution", category: "editor", targetId: "editor" },
{ titleKey: "settings.continueOnErrorOnBatch", category: "editor", targetId: "editor" },
{ titleKey: "settings.dataGridQuickEntry", category: "appearance", targetId: "appearance" },
{ titleKey: "settings.dataGridQuickEntry", category: "data", targetId: "data" },
{ titleKey: "transfer.dataTransfer", category: "appearance", targetId: "appearance" },
{ titleKey: "toolbar.driverManager", category: "appearance", targetId: "appearance" },
{ titleKey: "toolbar.theme", category: "appearance", targetId: "appearance" },
@@ -155,8 +155,8 @@ describe("settings search", () => {
{ titleKey: "settings.sqlFormatterParamTypes", category: "formatter", targetId: "formatter" },
{ titleKey: "settings.routineSourceOpenMode", category: "navigation", targetId: "navigation" },
{ titleKey: "settings.disconnectTabHandlingMode", category: "navigation", targetId: "navigation" },
{ titleKey: "settings.compactColumnHeaderActions", category: "appearance", targetId: "appearance" },
{ titleKey: "settings.infiniteScrollMaxRows", category: "appearance", targetId: "appearance" },
{ titleKey: "settings.compactColumnHeaderActions", category: "data", targetId: "data" },
{ titleKey: "settings.infiniteScroll", category: "data", targetId: "data" },
{ titleKey: "settings.globalDateTimeDisplayFormat", category: "data", targetId: "data" },
{ titleKey: "settings.globalDateTimeExportFormat", category: "data", targetId: "data" },
{ titleKey: "settings.globalDateTimeImportFormat", category: "data", targetId: "data" },